Converting date formats in pandas dataframe

前端 未结 3 2017
感情败类
感情败类 2021-01-24 14:07

I have a dataframe and the Date column has two different types of date formats going on.

eg. 1983-11-10 00:00:00 and 10/11/1983

I want them all to b

3条回答
  •  感情败类
    2021-01-24 14:36

    Input date is NSECODE Date Close 1 NSE500 20000103 1291.5500 2 NSE500 20000104 1335.4500 3 NSE500 20000105 1303.8000

    history_nseindex_df["Date"] = pd.to_datetime(history_nseindex_df["Date"])
    history_nseindex_df["Date"] = history_nseindex_df["Date"].dt.strftime("%Y-%m-%d")
    

    ouput is now NSECode Date Close 1 NSE500 2000-01-03 1291.5500 2 NSE500 2000-01-04 1335.4500 3 NSE500 2000-01-05 1303.8000

提交回复
热议问题