Pandad Set Timestamp Column as Index

February 24, 2021
import pandas as pd 

items = [
  {'date': '2020-01-01', 'score': 1},
  {'date': '2020-01-01', 'score': 2},
  {'date': '2020-01-01', 'score': 3}
]

df = pd.DataFrame(items) 
df['date'] = pd.to_datetime(df['date'], format='%Y-%m-%d')
df.set_index('date', inplace=True)
            score
date             
2020-01-01      1
2020-01-01      2
2020-01-01      3
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.