'Qualifying the timeseries data as year wise data using pd.infer_freq()
How to qualify the timeseries data as year wise data using pd.infer_freq() as using pd.infer_freq() only give cfrequency checks on months and days but not years .how can we automate it
import pandas as pd
df = pd.DataFrame({'Date': ['2005-01-01', '2005-02-01', '2005-03-01', '2005-04-01'],
'Date1': ['2005-01-01', '2005-01-02', '2005-01-03', '2005-01-04'],
'Date2': ['2006-01-01', '2007-01-01', '2008-01-01', '2009-01-01'],
'Date3': ['2006-01-01', '2006-02-06', '2006-03-11', '2006-04-01']})
df['Date'] = pd.to_datetime(df['Date'])
df['Date1'] = pd.to_datetime(df['Date1'])
df['Date2'] = pd.to_datetime(df['Date2'])
df['Date3'] = pd.to_datetime(df['Date3'])
o/p :
pd.infer_freq(df.Date)
'MS'
pd.infer_freq(df.Date1)
'D'
pd.infer_freq(df.Date2)
'AS-JAN
'
But how do i get Year
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|