0

I have two column in a pandas dataframe. First column is time+date and second column is price. But when it comes to 00:00:00 on a new day the time is omitted. How can I add 00:00:00 back to those cell which doesn't have time? I have tried splitting the cell by a space but it doesn't work since those cell in question doesn't have space. Thanks a lot

Now:

           datetime  Price
29.11.2018 16:00:00  05929
29.11.2018 17:00:00  05922
30.11.2018           05345
01.12.2018           05325

What I want to achieve:

           datetime  Price
29.11.2018 16:00:00  05929
29.11.2018 17:00:00  05922
30.11.2018 00:00:00  05345
01.12.2018 00:00:00  05325
Adam Cheng
  • 183
  • 1
  • 1
  • 6
  • 1
    What is in those empty cells? An empty string? NaN? – timgeb Nov 29 '18 at 20:56
  • 2
    The `'datetime'` column is probably filled with strings. Try `df['datetime'] = pd.to_datetime(df['datetime'])`. Pandas will show the `00:00:00` when there exist non-zero time elements in other cells. – piRSquared Nov 29 '18 at 20:56
  • Try `pd.to_datetime`. If that doesn't work, provide a [mcve]. – jpp Nov 29 '18 at 21:08

0 Answers0