I have a DataFrame that features two time columns. I want to reindex or create a new DataFrame with an index that covers the total time of those columns and I want the times in those columns to be used to label rows in the reindexed or new DataFrame. How might this be done efficiently?
df = pd.read_csv("NBER_chronology.csv")#
http://www.nber.org/cycles/NBER%20chronology.xlsx
df["Peak month"] = pd.to_datetime(df["Peak month"])
df["Trough month"] = pd.to_datetime(df["Trough month"])
df.tail()
The index could be defined in the following way:
pd.date_range(start = df["Trough month"].values[0], end = df["Trough month"].values[-1])
However, I feel that taking this route is a bit too manual.