Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 正在清理其绘图显示不稳定曲线的时间序列_Python_Pandas_Datetime_Time Series_Seaborn - Fatal编程技术网

Python 正在清理其绘图显示不稳定曲线的时间序列

Python 正在清理其绘图显示不稳定曲线的时间序列,python,pandas,datetime,time-series,seaborn,Python,Pandas,Datetime,Time Series,Seaborn,我想绘制时间线,我的日期格式为日/月/年 在建立索引时,我会注意: # format Date test['DATA'] = pd.to_datetime(test['DATA'], format='%d/%m/%Y') test.set_index('DATA', inplace=True) 通过仔细检查,我发现月和日的解释是正确的: #the number of month reflect the month, not the day : correctly imported! test[

我想绘制时间线,我的日期格式为日/月/年

在建立索引时,我会注意:

# format Date
test['DATA'] = pd.to_datetime(test['DATA'], format='%d/%m/%Y')
test.set_index('DATA', inplace=True)
通过仔细检查,我发现月和日的解释是正确的:

#the number of month reflect the month, not the day : correctly imported!
test['Year'] = test.index.year
test['Month'] = test.index.month   
test['Weekday Name'] = test.index.weekday_name
然而,当我绘图时,我看到数据点的连接不稳定(尽管它们的分布似乎是正确的,因为我预计会有季节性):

我怀疑这可能与错误的日期有关,或者日期没有按正确的顺序排列,但找不到验证错误所在的方法

您能帮助验证如何正确导入我的timeseries吗


哦,这太简单了。我假设datetime是自动排序的,而不是必须排序:

test.loc['2018-01':'2018-03'].sort_index().index #sorted
test.loc['2018-01':'2018-03'].index #not sorted
这个问题可能会被删除或标记为重复,我让版主回答:

可能存在的副本
test.loc['2018-01':'2018-03'].sort_index().index #sorted
test.loc['2018-01':'2018-03'].index #not sorted