0

I have a date column in a dataframe but its type is string :

palma.Created_at[1:5]
- 1    2019-10-20 12:08:40 +0200
- 2    2019-10-20 12:08:40 +0200
- 3    2019-10-20 12:08:40 +0200
- 4    2019-10-20 12:08:40 +0200
- 5    2019-10-20 12:08:40 +0200
- Name: Created_at, dtype: object

and I want to be just like : 2019-10-20. So how to convert it like this and should I convert it to date type or no?

Santosh Aryal
  • 1,276
  • 1
  • 18
  • 41
  • can you post the raw output of `palma.Created_at[1:5]` without bullet points? – ignoring_gravity Dec 28 '19 at 10:47
  • Does this answer your question? [Keep only date part when using pandas.to\_datetime](https://stackoverflow.com/questions/16176996/keep-only-date-part-when-using-pandas-to-datetime) – Riccardo Bucco Dec 28 '19 at 10:58

1 Answers1

0

You could do

import pandas as pd

palma.Created_at = pd.to_datetime(palma.Created_at).dt.date
ignoring_gravity
  • 6,677
  • 4
  • 32
  • 65