%matplotlib inline
import pandas as pd
vehicles = pd.read_csv("vehicles.csv")
vehicles.head()
citympgfloat64
cylindersint64
0
14.0
6
1
14.0
8
2
18.0
8
3
21.0
6
4
14.0
8
vehicles.plot(kind = 'scatter', x = 'citympg',y='co2emissions')
/shared-libs/python3.9/py/lib/python3.9/site-packages/pandas/plotting/_matplotlib/core.py:1041: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
scatter = ax.scatter(
vehicles['co2emissions'].plot(kind='hist')
vehicles.pivot(columns='drive',values='co2emissions')
2-Wheel Drivefloat64
328.3870968 - 987.4444444
4-Wheel Drivefloat64
294.0 - 829.0
0
555.4375
nan
1
555.4375
nan
2
484.7619048
nan
3
nan
nan
4
nan
nan
5
nan
nan
6
nan
nan
7
467.7368421
nan
8
423.1904762
nan
9
444.35
nan
vehicles.pivot(columns = 'drive', values = 'co2emissions').plot(kind='box',figsize = (10,6))
vehicles.groupby('year')['drive'].value_counts()
vehicles.groupby('year')['drive'].value_counts().unstack()
2-Wheel Drivefloat64
1.0 - 477.0
4-Wheel Drivefloat64
1.0 - 173.0
1984
477.0
nan
1985
nan
nan
1986
nan
1.0
1987
nan
nan
1988
nan
nan
1989
nan
nan
1990
nan
nan
1991
nan
nan
1992
nan
nan
1993
nan
nan
vehicles.groupby('year')['drive'].value_counts().unstack().plot(kind='bar',stacked=1, figsize=(10,6))