Can someone explain what means parse_dates=["trans_date"] in pd.read_csv?

Screen Link:

My Code:

pd.read_csv("rfm_xmas19.txt", parse_dates=["trans_date"])```

When I try 

pd.read_csv(“rfm_xmas19.txt”)

I didnt notice some difference. 

Can someone explain what means **parse_dates=["trans_date"]** in pd.read_csv?
2 Likes

parse_dates=["trans_date"]means It will try parsing given column trans_date into datetime data type.


Without parse_dates datatype of trans_date column is Object

data = pd.read_csv("rfm_xmas19.txt")
print(data.dtypes)

customer_id    object
trans_date     object
tran_amount     int64
dtype: object

With parse_dates data type of trans_date column is datetime64[ns]

data = pd.read_csv("rfm_xmas19.txt", parse_dates=["trans_date"])
print(data.dtypes)

customer_id            object
trans_date     datetime64[ns]
tran_amount             int64
dtype: object
3 Likes