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

Drop The Columns - Id - and - Unnamed - 0 - From Axis...

The document contains Python code that reads a CSV dataset into a pandas DataFrame, drops unnecessary columns, and prints a statistical summary of the remaining data. The dataset includes various attributes related to cars, such as make, fuel type, and engine specifications. Additionally, it references several online resources related to AI and machine learning.

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)
15 views3 pages

Drop The Columns - Id - and - Unnamed - 0 - From Axis...

The document contains Python code that reads a CSV dataset into a pandas DataFrame, drops unnecessary columns, and prints a statistical summary of the remaining data. The dataset includes various attributes related to cars, such as make, fuel type, and engine specifications. Additionally, it references several online resources related to AI and machine learning.

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,Unnamed:
0,symboling,normalized-losses,make,fuel-type,aspiration,num-of-doors,body-style,drive-wheels,engin
e-location,wheel-base,length,width,height,curb-weight,engine-type,num-of-cylinders,engine-size,fuel-
system,bore,stroke,compression-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,dohc,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,dohc,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,ohcv,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,136,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,mpfi,3.19,3.40,8.5,110,550
0,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,5
500,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,550
0,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,131,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,five,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())​

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://microsoftlearning.github.io/AI-900-AIFundamentals/instructions/02a-create-regression-m
odel.html
2. https://github.com/AnandaSP/MyAI
3. https://github.com/FauziMaulana/LearnMachineLearning
4. https://github.com/mariamtolu/demo
5. https://github.com/Julian0927/Data-Analysis-with-Python

You might also like