0
$\begingroup$

I want to extract the month and year from one of my date columns in the dataset and create a new column in the data-frame with the new MM-YYY format.

My current solution is working fine but its way to long. I am looking for an efficient way to do this.

Date point looks like this: 2017-07-26 and its in datetime64[ns] format and I want the output to look like this: Jul-2017

$\endgroup$

1 Answer 1

0
$\begingroup$
import datetime
df1['Month'] = df1['booking_date'].apply(lambda x: datetime.datetime.strftime(x, "%B-%Y"))
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.