Python ProgrammingPython Programming

Determine Period Index and Column for DataFrame in Pandas

Determine Period Index and Column for DataFrame:

import pandas as pd

values = ["India", "Canada", "Australia",
          "Japan", "Germany", "France"]

pidx = pd.period_range('2015-01-01', periods=6)

df = pd.DataFrame(values, index=pidx, columns=['Country'])

print(df)


C:\pandas>python example.py
              Country
2015-01-01      India
2015-01-02     Canada
2015-01-03  Australia
2015-01-04      Japan
2015-01-05    Germany
2015-01-06     France
 
C:\pandas>