In [1]:
import pandas as pd
In [2]:
df = pd.read_csv('result.csv')
df.head()
Out[2]:
Order_ID Product Quantity Price Total Order_Date Address Month
0 176558 USB-C Charging Cable 2 11.95 23.90 2019-04-19 08:46:00 917 1st St, Dallas, TX 75001 4
1 176559 Bose SoundSport Headphones 1 99.99 99.99 2019-04-07 22:30:00 682 Chestnut St, Boston, MA 02215 4
2 176560 Google Phone 1 600.00 600.00 2019-04-12 14:38:00 669 Spruce St, Los Angeles, CA 90001 4
3 176560 Wired Headphones 1 11.99 11.99 2019-04-12 14:38:00 669 Spruce St, Los Angeles, CA 90001 4
4 176561 Wired Headphones 1 11.99 11.99 2019-04-30 09:27:00 333 8th St, Los Angeles, CA 90001 4
In [7]:
pd.set_option('display.float_format', lambda x: '%.0f' % x)
res = df.groupby('Month')[['Total']].sum()
res
Out[7]:
Total
Month
1 1822257
2 2202022
3 2807100
4 3390670
5 3152607
6 2577802
7 2647776
8 2244468
9 2097560
10 3736727
11 3199603
12 4613443
In [4]:
4.613443e+06
Out[4]:
4613443.0
In [20]:
ax = res.plot(kind='bar', grid=True)
ax.set_ylabel('USD (mln.)')
ax.get_yaxis().get_major_formatter().set_scientific(False)
In [21]:
import matplotlib.pyplot as plt
In [29]:
plt.bar(res.index, res.Total)
plt.xticks(range(1, 13))
plt.yticks(range(0, 5000000, 500000))
plt.gcf().axes[0].yaxis.get_major_formatter().set_scientific(False)
plt.grid()
plt.show()
In [30]:
plt.rcParams['figure.figsize']
Out[30]:
[6.0, 4.0]
In [31]:
plt.rcParams['figure.figsize'] = [12, 8]
In [54]:
plt.bar(res.index, res.Total)
plt.xticks(range(1, 13))
plt.yticks(range(0, int(round(res.max()[0])), 500000))
plt.gcf().axes[0].yaxis.get_major_formatter().set_scientific(False)
plt.xlabel('Месяцы')
plt.ylabel('Выручка в $')

for index, value in enumerate(res.Total):
    plt.text(
        index+1,
        500000,
        '{0:,}'.format(round(value)).replace(',', ' '),
        rotation='vertical',
        size='20',
        color='#fff',
        ha='center')

# plt.grid()
plt.show()
In [37]:
int(round(res.max()[0]))
Out[37]:
4613443
In [52]:
'{0:,}'.format(round(1822256.72)).replace(',', ' ')
Out[52]:
'1 822 257'
In [ ]: