Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas group by month

b = pd.read_csv('b.dat')
b.index = pd.to_datetime(b['date'],format='%m/%d/%y %I:%M%p')
b.groupby(by=[b.index.month, b.index.year])
# or
b.groupby(pd.Grouper(freq='M'))  # update for v0.21+
# or
df.groupby(pd.TimeGrouper(freq='M'))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #group #month
ADD COMMENT
Topic
Name
1+2 =