Why can't I make a new column in pandas using the strftime() function?

I was trying to make a column of minute times from the datetime column in the table. I thought you could just apply functions to existing columns, and assign the values to a new column. What’s the best way to do this?

You are trying to call a method that doesn’t exist.
As the error tells you, Pandas Series objects don’t have a strftime() method. That method is supported by date, datetime and time objects. See documentation here.

What you want to do is to call that method on the actual datetime objects that are contained in the column, rather than on the column itself.

Have you done the lesson on using .apply() and lambda functions in Pandas?

2 Likes