Issue
I have a table with one column which denotes a date. The date is displayed as MM/YY. I need to find all dates which are in the year 2025.
I have done the following:
ecom["Date"].str[3:]
So that I only have the year.
ecom["Date"].str[3:] == 25
This return a bunch of Booleans which are all false even when they are in the year 2025.
This is because:
ecom["Date"].str[3:]
Is not a number. If I input
int(ecom["Date"].str[3:])
I am told that
cannot convert the series to <class 'int'>
I would like to know how to implement int (or similar). I am also well aware I can declare 25 as a string as this also works however I would like to know specifically how to turn ecom["Date"].str[3:] into a number.
Many Thanks
Solution
As stated by FHTMitchell pd.to_numeric
is the better option.
Answered By - Oliver Brace
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.