Professional Documents
Culture Documents
In [56]: shipping_data[shipping_data['ShippedUnits']>3]
2 UK 2007-10-06 2007-10-15 b 10
file:///C:/Users/adrie/Downloads/Python_Exercises.html 7/14
18/07/2023 18:21 Python_Exercises
In [75]: import os
In [76]: os.getcwd()
'/content'
Out[76]:
In [77]: path="sample_data/"
In [78]: path
'sample_data/'
Out[78]:
In [81]: path+'shippments.xlsx'
'sample_data/shippments.xlsx'
Out[81]:
In [82]: df1=shipping_data[shipping_data['Country']=='France']
with pd.ExcelWriter(path+'shippments.xlsx') as writer:
df1.to_excel(writer, sheet_name='France')
In [83]: df2=shipping_data[shipping_data['Country']=='Belgimu']
with pd.ExcelWriter(path+'shippments.xlsx', engine='openpyxl', mode='a') as writer
df2.to_excel(writer, sheet_name='Belgium')
In [84]: shipping_data['ShippedUnits'].plot.hist()
<Axes: ylabel='Frequency'>
Out[84]:
file:///C:/Users/adrie/Downloads/Python_Exercises.html 8/14
18/07/2023 18:21 Python_Exercises
In [85]: shipping_data['Country'].value_counts().plot(kind='bar')
<Axes: >
Out[85]:
In [ ]:
EXERCISE 4
file:///C:/Users/adrie/Downloads/Python_Exercises.html 9/14
18/07/2023 18:21 Python_Exercises
In [100… tims=shipping_data.groupby('OrderDate').sum()
tims.head()
OrderDate
2007-10-01 10
2007-10-02 2
2007-10-06 16
2007-10-09 3
2007-10-11 13
In [101… tims.plot()
tims.cumsum().plot()
<Axes: xlabel='OrderDate'>
Out[101]:
file:///C:/Users/adrie/Downloads/Python_Exercises.html 10/14
18/07/2023 18:21 Python_Exercises
EXERCISE 5
OrderDate Country
2007-10-01 Belgium 10
2007-10-02 Germany 2
2007-10-06 Belgium 6
UK 10
2007-10-09 Germany 3
In [104… tims.head()
file:///C:/Users/adrie/Downloads/Python_Exercises.html 11/14
18/07/2023 18:21 Python_Exercises
Out[104]: ShippedUnits
OrderDate
In [107… tims.head()
Out[107]: ShippedUnits
OrderDate
In [108… tims.cumsum().plot()
<Axes: xlabel='OrderDate'>
Out[108]:
file:///C:/Users/adrie/Downloads/Python_Exercises.html 12/14
18/07/2023 18:21 Python_Exercises
In [ ]:
EXERCISE 6
In [112… yields.head()
file:///C:/Users/adrie/Downloads/Python_Exercises.html 13/14
18/07/2023 18:21 Python_Exercises
Out[112]: GS10
DATE
2018-08-01 2.89
2018-09-01 3.00
2018-10-01 3.15
2018-11-01 3.12
2018-12-01 2.83
In [113… yields.plot()
<Axes: xlabel='DATE'>
Out[113]:
In [ ]:
file:///C:/Users/adrie/Downloads/Python_Exercises.html 14/14