2
I have a DataFrame
and needed to give a split
in his date field to later add month and day columns.
The problem is that the field data
Dataframe is not the type str
, so I can’t use the method split
.
Structure of the Dataframe
data usuarios
2018-01-01 215.0
Goal
data usuarios ano mes
2018-01-01 215.0 2018 01
Attempts
# df.data.apply(str)
# df["data"].apply(str)
# df["data"].astype(basestring)
df.data.str.split("-")
I’ve tried those ways but none of them solved my problem.
I also tried using the official documentation but I couldn’t solve it either.
Error Displayed
Attributeerror: Can only use . str accessor with string values!
you could mark one of the answers as accepted. Understand the importance of this link: https://pt.meta.stackoverflow.com/questions/1078/como-e-por-que-aceitar-uma-reply
– Lucas