Note
- This tutorial is also available on nbviewer, offering an alternative platform for your learning convenience.
- 🔥 Free Pandas Course: https://hedaro.gumroad.com/l/tqqfq
Some nifty ninjastics you can do with Group By and MatPlotLib.
Here is the csv data if you want to follow along:
Date,Symbol,Volume
1/1/2013,A,0
1/2/2013,A,200
1/3/2013,A,1200
1/4/2013,A,1001
1/5/2013,A,1300
1/6/2013,A,1350
3/8/2013,B,500
3/9/2013,B,1150
3/10/2013,B,1180
3/11/2013,B,2000
1/5/2013,C,56600
1/6/2013,C,45000
1/7/2013,C,200
5/20/2013,E,1300
5/21/2013,E,1700
5/22/2013,E,900
5/23/2013,E,2100
5/24/2013,E,8000
5/25/2013,E,12000
5/26/2013,E,1900
5/27/2013,E,1000
5/28/2013,E,1900
Python version 3.11.7 | packaged by Anaconda, Inc. | (main, Dec 15 2023, 18:05:47) [MSC v.1916 64 bit (AMD64)]
Pandas version 2.2.1
Date | Symbol | Volume | |
---|---|---|---|
0 | 1/1/2013 | A | 0 |
1 | 1/2/2013 | A | 200 |
2 | 1/3/2013 | A | 1200 |
3 | 1/4/2013 | A | 1001 |
4 | 1/5/2013 | A | 1300 |
You are going to have to change the data type of the Date column
Date object
Symbol object
Volume int64
dtype: object
Date datetime64[ns]
Symbol object
Volume int64
dtype: object
Date | Symbol | Volume | Gender | |
---|---|---|---|---|
0 | 2013-01-01 | A | 0 | boy |
1 | 2013-01-02 | A | 200 | girl |
2 | 2013-01-03 | A | 1200 | boy |
3 | 2013-01-04 | A | 1001 | girl |
4 | 2013-01-05 | A | 1300 | boy |
Group one column and plot
<class 'tuple'>
//////
<class 'tuple'>
//////
<class 'tuple'>
//////
<class 'tuple'>
//////
Group two columns and plot
('A', 'boy')
('A', 'girl')
('B', 'boy')
('B', 'girl')
('C', 'boy')
('C', 'girl')
('E', 'boy')
('E', 'girl')