簡體   English   中英

如何在 python 中的數據集中排除一系列日期?

[英]how can i exclude a range of dates in my data set in python?

我想知道是否有一種方法可以提取日期,例如,我想要某個特定日期的每一天:

from 2015-10-1 to 2016-3-31
from 2016-10-1 to 2016-3-31,
from 2016-10-1 to 2017-3-31, etc

我想選擇直到我的數據集結束的所有日期

如果您使用 Pandas 數據幀df將日期時間值作為表使用的索引

import pandas as pd
idx = pd.date_range('2015-01-01', periods=1096, freq='D')
df = pd.Series(range(len(idx)), index=idx)

# select only JAN to MARCH and OCT to DEC
df[~((df.index.month > 3) & (df.index.month < 10))]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM