[英]How can I subset a data frame based on dates, when my dates column is not the index in 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.