【发布时间】:2021-02-03 02:44:20
【问题描述】:
【问题讨论】:
标签: python pandas matplotlib seaborn data-science
【问题讨论】:
标签: python pandas matplotlib seaborn data-science
如果您的日期存储为日期时间对象,那么您可以使用以下内容:
import seaborn as sns
years=df['date'].dt.year
sns.distplot(years)
对于标签,您可以使用:
label=1#0, you choose
df_lab=df.loc['label'==label]
years_label=df_lab['date'].dt.year
sns.distplot(years_label)
【讨论】:
years=pd.to_datetime(df['date']).dt.year
df['year']=df['date'].dt.year sns.distplot(df,x='years')