Home > Enterprise >  Creating a year-quarter object in python
Creating a year-quarter object in python

Time:06-11

I have a string

YearQtr = '2002-Q1'

Is there any way to convert above string to pandas date object with quarter format?

CodePudding user response:

Sure, use Period:

p = pd.Period(YearQtr, freq='Q')
print (p)
2002Q1

Or:

p = pd.Period(YearQtr)
  • Related