I have some columns in my dataframe for which I just want to keep the date part and remove the time part. I have made a list of these columns:
list_of_cols_to_change = ['col1','col2','col3','col4']
I have written a function for doing this. It takes a list of columns and applies dt.date to each column in the list.
def datefunc(x):
for column in x:
df[column] = df[column].dt.date
I then call this function passing the list as parameter:
datefunc(list_of_cols_to_change )
I want to accomplish this using something like map(). Basically use a function what takes a column as parameter and makes changes to it. I then want to use map() to apply this function to the list of columns that I have. Something like this:
def datefunc_new(column):
df[column] = df[column].dt.date
map(datefunc_new,list_of_cols_to_change)
This does not work however. How can I make this work ?