import numpy as np
import pandas as pd
# create time-indexed data frame
arr = np.random.randn(100)
cols = {f'column_{i}': arr for i in range(3)}
df = pd.DataFrame(data=cols, index=pd.date_range('2019-01-01', periods=len(arr)))
df.tail()
df.to_feather('time-indexed-df.feather')
# what does `reset_index()` do?
df.reset_index().tail()
# reset index and write to feather in one step
df.reset_index().to_feather('time-indexed-df.feather')
Success!!
# read it back in
df = pd.read_feather('time-indexed-df.feather')
df.set_index('index', inplace=True)
df.tail()
# ...or in one step:
df = pd.read_feather('time-indexed-df.feather').set_index('index')
df.tail()