Raul Torres
Raul Torres

Reputation: 1

Change a string in a column to an integer in pandas

enter image description heretable of movie data

As you can see the column of release date puts the month in a string. I want to change all of them into numbers. For example, Dec 18, 2009 can just be 12. I am not interested in the year.

Update: I think I got it. They still come out as objects when I do .info() but at least I was able to get to the number

Upvotes: 0

Views: 75

Answers (1)

Ynjxsjmh
Ynjxsjmh

Reputation: 30032

You can convert it to datetime and use Series.dt.month

df['release date'] = pd.to_datetime(df['release date']).dt.month
print(df)

   release date
0            12

Upvotes: 1

Related Questions