sehHeiden
Missing functions in Explorer DataFrames/Series
Compared to Pythons pandas I am missing some functions for DataFrames and Series from Explorer, or I have to apply a workaround, which makes everything less expressive.
DataFrames have a drop_nil function. Why don’t have Series have it? Well, I can convert it to list, drop them from the list and then convert back…
By the documentation the series have a contains function, that use a regex, could not get with working with a compiled regex string. I did a mapping instead:
filter = df["content"]
|> S.to_list()
|> Enum.map(&Regex.match?(tags,&1))
|> S.from_list()
This returns a series of boolean. But I can not use it filter a DataFrame or a Series? At least I did not find it in the reference and also no way around. It neighter a filter, filter_with nor a slice. Slice needs indices. How do I get the indices, where the value is :true?
The last question is, about Date(time) columns. How can I convert a Date to a calendar week?
Update:
post_filter = df["content"]
|> S.downcase()
|> S.to_list()
|> Enum.map(&Regex.match?(tags,&1))
|> Enum.with_index()
|> Enum.filter(&(elem(&1, 0) == true))
|> Enum.map(&(elem(&1, 1)))
Can be used as input for the slicing…
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 10 of 13 Posts
billylanchantin
I believe you want
Explorer.Series.mask/2.billylanchantin
Sorry I missed this part. Also I’m not sure what a “calendar week” is. Is that the index of the week in the calendar year? If so this could work:
josevalim
We will also gladly accept PRs that add missing functions. We know that we are missing many of them.
sehHeiden
Thanks. @billylanchantin the mask function helped alot. Sorry, that I was not able find it.
The calendar week is somewhat more complex, because it first week of the year, might partly be counted as the last week of the year before. I had to look it up. Normally I would expect it to be a part of the date(time) library
wikipedia states the ISO week date computes as:
Algorithm
The edge cases below, Is what I meant and makes me wonder, whether I really understand these.
billylanchantin
You’re welcome. And no worries! There are a lot of functions to sift through.
Ah gotcha. Yeah that looks tricky to implement yourself.
As @josevalim said, there are missing functions. If you look at the Elixir side of things:
They do not have a function that corresponds to what you want. But you’re in luck because Polars does!
Unless I’m missing something, it should be straightforward to add that function to Explorer if you wanted to do a PR
josevalim
And if you can’t submit a PR, open up an issue and we will look into it
sehHeiden
Sorry for answering late. The messages from the elixir-forum always end up in my spam filter. About the PR… a) a I very new to Elixir not so bold to mess up some core libraries
. Also barely have to time.
But creating an issue is doable.
billylanchantin
Hi @sehHeiden,
The function is now on
main(José reviews PRs quick!):So if you get the latest ref, you can now do:
Since you’re new to Elixir, you can get the latest ref by adding the following to your project’s
mix.exs:There are other ways of doing this too, but that should get you started.
sehHeiden
Thanks for your message @billylanchantin . I did have a look at the commits. Have been many changes for appyling a single function.
sehHeiden
Hi @billylanchantin I tried, to do so: I get a error message from rustler:
I have no problem with building the hex version