In [1]: import pandas as pd
In [2]: import numpy as np
In [3]: salesman = pd.read_csv('Pandas/pandas/salesmen.csv', parse_dates=['Date'])
In [4]: salesman.head(5)
Out[4]:
Date Salesman Revenue
0 2016-01-01 Bob 7172
1 2016-01-02 Bob 6362
2 2016-01-03 Bob 5982
3 2016-01-04 Bob 7917
4 2016-01-05 Bob 7837
In [7]: salesman['Salesman'].value_counts()
Out[7]:
Ronald 366
Bob 366
Dave 366
Oscar 366
Jeb 366
Name: Salesman, dtype: int64
In [6]: salesman.pivot(index='Date',columns='Salesman',values='Revenue').head(5)
Out[6]:
Salesman Bob Dave Jeb Oscar Ronald
Date
2016-01-01 7172 1864 4430 5250 2639
2016-01-02 6362 8278 8026 8661 4951
2016-01-03 5982 4226 5188 7075 2703
2016-01-04 7917 3868 3144 2524 4258
2016-01-05 7837 2287 938 2793 7771
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment