Untitled
unknown
python
3 years ago
715 B
27
Indexable
import pandas as pd
df = pd.read_csv("//home//it//Downloads//Automobile_data.csv")
# print first and last
print('_________________________')
print(df.head(5))
print(df.tail(5))
# most expensive car
print('_________________________')
ex = df[['company','price']][df.price==df['price'].max()]
print(ex)
# print all toyota cars details
print('_________________________')
car_manufacture=df.groupby('company')
toyota =car_manufacture.get_group('toyota')
print(toyota)
# count total cars details
print('_________________________')
print(df['company'].value_counts())
# average mileage of each car
print('_________________________')
ls=['company','average-mileage']
mileage= car_manufacture[ls].mean()
print(mileage)Editor is loading...