0% found this document useful (0 votes)
10 views3 pages

Use The Method Value - Counts To Count The Number O...

The document contains Python code that processes two datasets using pandas. The first dataset relates to housing information, where it counts unique floor values and prints the results. The second dataset pertains to car specifications, where it drops unnecessary columns and provides a statistical summary of the remaining data.

Uploaded by

lizeth1027210995
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Use The Method Value - Counts To Count The Number O...

The document contains Python code that processes two datasets using pandas. The first dataset relates to housing information, where it counts unique floor values and prints the results. The second dataset pertains to car specifications, where it drops unnecessary columns and provides a statistical summary of the remaining data.

Uploaded by

lizeth1027210995
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Python

import pandas as pd​


import io​

data =
"""id,floors,bedrooms,bathrooms,sqft_living,sqft_lot,waterfront,view,condition,grade,sqft_above,sqft_ba
sement,yr_built,yr_renovated,zipcode,lat,long,sqft_living15,sqft_lot15,price​
1,1.0,3,1.0,1180,5650,0,0,3,7,1180,0,1955,0,98178,47.5112,-122.257,1340,5650,221900​
2,1.0,3,2.25,2770,10000,0,2,3,6,2770,0,1933,0,98022,47.5333,-122.172,1550,10000,538000​
3,1.0,2,1.0,770,10000,0,0,3,6,770,0,1933,0,98028,47.7379,-122.233,2720,8062,180000​
4,1.0,4,3.0,1960,5000,0,0,5,7,1050,910,1965,0,98136,47.5208,-122.393,1360,5000,604000​
5,1.0,3,2.0,1680,8080,0,0,3,8,1680,0,1987,0,98074,47.6168,-122.045,1800,7503,510000​
6,1.5,3,2.25,1715,6819,0,0,3,7,1715,0,1995,0,98003,47.3097,-122.327,2238,6819,257500​
7,1.0,3,2.0,1060,6435,0,0,3,7,1060,0,1954,0,98168,47.4762,-122.33,1650,9711,414500​
8,1.0,3,1.0,1780,16200,0,0,3,7,1050,730,1960,0,98146,47.5122,-122.322,1550,12200,485000​
9,2.5,3,2.5,1890,6560,0,0,3,7,1890,0,2003,0,98038,47.3563,-122.005,2240,7570,322000​
10,1.0,3,2.5,3560,9796,0,0,3,8,1860,1700,1965,0,98007,47.6007,-122.145,2210,8925,530000​
"""​

df = pd.read_csv(io.StringIO(data))​

# Count the number of houses with unique floor values​
floor_counts = df['floors'].value_counts()​

# Convert the Series to a DataFrame​
floor_counts_df = floor_counts.to_frame(name='count')​

# Print the DataFrame​
print(floor_counts_df)​

1.​ floor_counts = df['floors'].value_counts()​


floor_counts_df = floor_counts.to_frame(name='count')​
print(floor_counts_df)​

import pandas as pd

import io
data = """id,Unnamed:
0,symboling,normalized-losses,make,fuel-type,aspiration,num-of-doors,body-s
tyle,drive-wheels,engine-location,wheel-base,length,width,height,curb-weight,
engine-type,num-of-cylinders,engine-size,fuel-system,bore,stroke,compressio
n-ratio,horsepower,peak-rpm,city-mpg,highway-mpg,price

1,0,3,?,alfa-romero,gas,std,two,convertible,rwd,front,88.6,168.8,64.1,48.8,2548,d
ohc,four,130,mpfi,3.47,2.68,9.0,111,5000,21,27,13495

2,1,3,?,alfa-romero,gas,std,two,convertible,rwd,front,88.6,168.8,64.1,48.8,2548,d
ohc,four,130,mpfi,3.47,2.68,9.0,111,5000,21,27,16500

3,2,1,?,alfa-romero,gas,std,two,hatchback,rwd,front,94.5,171.2,65.5,52.4,2823,oh
cv,six,152,mpfi,2.68,3.47,9.0,154,5000,19,26,16500

4,3,2,164,audi,gas,std,four,sedan,fwd,front,99.8,176.6,66.2,54.3,2337,ohc,four,109
,mpfi,3.19,3.40,10.0,102,5500,24,30,13950

5,4,2,164,audi,gas,std,four,sedan,4wd,front,99.4,176.6,66.4,54.3,2824,ohc,five,13
6,mpfi,3.19,3.40,8.0,115,5500,18,22,17450

6,5,2,?,audi,gas,std,two,sedan,fwd,front,99.8,177.3,66.3,53.1,2507,ohc,five,136,m
pfi,3.19,3.40,8.5,110,5500,19,25,15250

7,6,1,158,audi,gas,std,four,sedan,fwd,front,105.8,192.7,71.4,55.7,2844,ohc,five,136
,mpfi,3.19,3.40,8.5,110,5500,19,25,17710

8,7,1,?,audi,gas,std,four,wagon,fwd,front,105.8,192.7,71.4,55.7,2954,ohc,five,136,
mpfi,3.19,3.40,8.5,110,5500,19,25,18920

9,8,1,158,audi,gas,turbo,four,sedan,fwd,front,105.8,192.7,71.4,55.9,3086,ohc,five,1
31,mpfi,3.13,3.40,8.3,140,5500,17,20,23875

10,9,0,?,audi,gas,turbo,two,hatchback,4wd,front,99.5,178.2,67.9,52.0,3053,ohc,fi
ve,131,mpfi,3.13,3.40,7.0,160,5500,16,22,?

"""

df = pd.read_csv(io.StringIO(data))

# Drop the columns "id" and "Unnamed: 0"

df.drop(labels=['id', 'Unnamed: 0'], axis=1, inplace=True)


# Obtain a statistical summary of the data

print(df.describe())

Fuentes
1. https://github.com/josepablocam/wranglesearch
2. https://github.com/Shaharuf/Data-analysis-with-Python

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy