I want to convert index of my time series DataFrame into datetime. The problem is that some of index is timestamp and some datetime.
time C1
2020-10-18 13:38:43.349 0.046
2020-10-18 13:52:34.104 0.099
1602824859304 1.000
1602824934121 0.007
This: df['time'] = pd.to_datetime(df['time'], unit='ms')
Yields: ValueError: non convertible value time with the unit 'ms'
This: df["time"] = df["time"].apply(lambda x: pd.to_datetime(x,errors='ignore').strftime('%Y-%m-%d %H:%M') if len(x) !=0 else "----")
Yields: AttributeError: 'str' object has no attribute 'strftime'
This is a similar question but isn't applicable in my case:
Convert dataframe column to datetime only if length of string is not zero
My expected output is all index rows being datetime format.