Reputation: 955
I have a main data frame called df
which contains many columns, including shipment_date
and order_date
. I want to create a new data frame that contains only order_date
and the difference.
I've calculated the difference:
df_ship_diff = df['shipment_date'] - df['order_date']
How do I create a title for df_ship_diff? And how do I create a new data frame with df_ship_diff
and order_date
?
Upvotes: 0
Views: 40
Reputation: 556
Try this :
df_ship_diff = df.copy()[["order_date"]]
df_ship_diff["title"] = df['shipment_date'] - df['order_date']
# To add other columns :
# df_ship_diff["new_col"] = Something
Upvotes: 2