Saturday, January 17, 2026
HomeLanguagesPython | Pandas PeriodIndex.freqstr

Python | Pandas PeriodIndex.freqstr

Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.

Pandas PeriodIndex.freqstr attribute return the frequency object as a string if its set, otherwise the function return None for the given PeriodIndex object.

Syntax : PeriodIndex.freqstr

Parameters : None

Return : frequency as a string
 

Example #1: Use PeriodIndex.freqstr attribute to find the time series frequency applied on the given PeriodIndex object. 

Python3




# importing pandas as pd
import pandas as pd
 
# Create the PeriodIndex object
pidx = pd.PeriodIndex(start ='2005-12-21 08:45 ',
              end ='2005-12-21 11:55', freq ='H')
 
# Print the PeriodIndex object
print(pidx)


Output : 

Now we will use the PeriodIndex.freqstr attribute to find the time series frequency of the given object.

Python3




# return the frequency object as a string
pidx.freqstr


Output : 

As we can see in the output, the PeriodIndex.freqstr attribute has returned ‘H’ indicating that hourly frequency is applied on the given PeriodIndex object. 
  
Example #2: Use PeriodIndex.freqstr attribute to find the time series frequency of the given PeriodIndex object.

Python3




# importing pandas as pd
import pandas as pd
 
# Create the PeriodIndex object
pidx = pd.PeriodIndex(start ='2011-02-1 ',
             end ='2011-08-14', freq ='M')
 
# Print the PeriodIndex object
print(pidx)


Output : 

Now we will use the PeriodIndex.freqstr attribute to find the time series frequency of the given object.

Python3




# return the frequency object as a string
pidx.freqstr


Output : 

As we can see in the output, the PeriodIndex.freqstr attribute has returned ‘M’ indicating that monthly frequency is applied on the given PeriodIndex object.
 

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32474 POSTS0 COMMENTS
Milvus
118 POSTS0 COMMENTS
Nango Kala
6846 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12063 POSTS0 COMMENTS
Shaida Kate Naidoo
6985 POSTS0 COMMENTS
Ted Musemwa
7219 POSTS0 COMMENTS
Thapelo Manthata
6933 POSTS0 COMMENTS
Umr Jansen
6911 POSTS0 COMMENTS