Reputation: 13785
I have data of something like this in a TSV file, where the first column is date and the second column is value. <TAB>
is a tab character.
date<TAB>value
2021-1-1<TAB>1.4640974
2021-1-1<TAB>0.9145975
...
2021-5-31<TAB>2.4306027
2021-5-31<TAB>0.4966789
I want to plot the value in boxplots for different time periods like day, week and month. I've seen some old code for plotting time series data, but they are not very current.
Could anybody show me the current recommended way to plot the figures in python?
Upvotes: 1
Views: 724
Reputation: 14949
convert date column to datetime
and then use seaborn
:
import seaborn as sns
df.date = pd.to_datetime(df.date)
sns.boxplot(x=df['date'].dt.date, y=df['value'])
sns.boxplot(x=df['date'].dt.year, y=df['value'], hue=df['date'].dt.month)
Upvotes: 1