Hi, I want to filter my DataFrame by Date, but the column wich has the date has the following type:
Typeof(DateTime("2021-12-17T06:00:00"))
Feather.Arrow.Timestamp{Microsecond}
The column look like:
DateTime("2020-12-15T06:00:00")
DateTime("2020-12-19T06:00:00")
DateTime("2020-12-16T06:00:00")
DateTime("2020-12-18T06:00:00")
DateTime("2020-12-14T06:00:00")
DateTime("2020-12-20T06:00:00")
DateTime("2020-12-20T06:00:00")
DateTime("2020-12-14T06:00:00")
DateTime("2020-12-16T06:00:00")
DateTime("2020-12-17T06:00:00")
DateTime("2020-12-15T06:00:00")
DateTime("2020-12-20T06:00:00")
I tried to chop it, but again because of the type I couldnt it shows:
MethodError: no method matching chop(::Feather.Arrow.Timestamp{Microsecond}; head=10, tail=2) Closest candidates are: chop(::AbstractString; head, tail) at strings/util.jl:184
So I try to change the type using parse and convert but it is not allowed. In R I use filter and I have no problem. What can I do?
Thank u.
It depends on what you want to do exactly. Your data has both date and time encoded in it.
If you want to strip off the time and leave only the date part then do:
julia> DateTime("2020-12-15T06:00:00")
2020-12-15T06:00:00
julia> Date(DateTime("2020-12-15T06:00:00"))
2020-12-15
However, maybe you want to filter e.g. a specific year, then do:
julia> year(DateTime("2020-12-15T06:00:00"))
2020
(same for month, day, etc.)
If you provided a MWE what you want to achieve (i.e. exact input and desired output) I can help you with the proper syntax.
Ok , the problem I have is that the column of my date has the type upstairs (Feather.Arrow.Timestamp{Microsecond}) and the output looks like:
DateTime("2020-12-20T06:00:00")
rather than (with type DataTime) :
2021-12-17T06:00:00
Thats why I can´t filter by date, because of the type, but I can´t change it.
Right now I´m trying to copy the output and rewrite the column, but the type is giving me hard times.
I hope I make myself understood.
Thank u
It looks you should be able to convert
each Arrow Timestamp
to a DateTime
(in e.g., a Split-Apply-Combine workflow.) https://github.com/apache/arrow-julia/blob/1447cb2b13b728729f9a89760ac07a848e31e599/src/eltypes.jl#LL268-L271
It says that Timestamp its not defined, right now I´m thinking to rewrite the column by copying the output.