参考链接:
https://stackoverflow.com/questions/64106628/why-assertionerror-having-numpy-ndarray
df.index = pd.to_datetime(df.index)
df = df.sort_index()
df_sub = df['2018'] # select the whole year of 2018
df_sub2 = df
使用Pandas处理时间序列数据:选择特定年份与月份
这篇博客介绍了如何利用Pandas库对时间序列数据进行操作,包括将日期索引转换为datetime类型,按时间排序数据,并通过切片选择特定年份(如2018年)或特定月份(如2018年2月)的数据。此外,还展示了如何选取指定日期范围(如2018年1月至3月)的数据。这些技巧对于数据分析和时间序列分析至关重要。
参考链接:
https://stackoverflow.com/questions/64106628/why-assertionerror-having-numpy-ndarray
df.index = pd.to_datetime(df.index)
df = df.sort_index()
df_sub = df['2018'] # select the whole year of 2018
df_sub2 = df
1490
9107

被折叠的 条评论
为什么被折叠?