Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't iterate PrettyDict of Pandas #131

Open
colspan opened this issue Nov 18, 2020 · 0 comments
Open

Can't iterate PrettyDict of Pandas #131

colspan opened this issue Nov 18, 2020 · 0 comments
Assignees
Labels

Comments

@colspan
Copy link

colspan commented Nov 18, 2020

Iterating the result of Pandas.DataFrame.groupby fails with pandas>=1.1.0.
This failure seems to be caused by PrettyDict which is the alternative type of dict and added on pandas==1.1.0.
The log shows that pycall.rb can't regard PrettyDict as dict.

Reproduction code

require 'pandas'
df = Pandas.DataFrame.new([['a', 1], ['a', 1], ['b', 2]])
df.groupby(0).groups.each do |name, value|
    p name, value
end

pandas<1.1.0

"a"
Int64Index([0, 1], dtype='int64')
"b"
Int64Index([2], dtype='int64')

pandas>=1.1.0

TypeError: unexpected Python type PrettyDict (expected dict)
/home/jovyan/.bundle/ruby/2.7.0/gems/pycall-1.3.1/lib/pycall/dict.rb:38:in `dict_each'
/home/jovyan/.bundle/ruby/2.7.0/gems/pycall-1.3.1/lib/pycall/dict.rb:38:in `each'
<main>:1:in `<main>'
/home/jovyan/.bundle/ruby/2.7.0/gems/iruby-0.4.0/lib/iruby/backend.rb:44:in `eval'
/home/jovyan/.bundle/ruby/2.7.0/gems/iruby-0.4.0/lib/iruby/backend.rb:44:in `eval'
/home/jovyan/.bundle/ruby/2.7.0/gems/iruby-0.4.0/lib/iruby/backend.rb:12:in `eval'
/home/jovyan/.bundle/ruby/2.7.0/gems/iruby-0.4.0/lib/iruby/kernel.rb:90:in `execute_request'
/home/jovyan/.bundle/ruby/2.7.0/gems/iruby-0.4.0/lib/iruby/kernel.rb:49:in `dispatch'
/home/jovyan/.bundle/ruby/2.7.0/gems/iruby-0.4.0/lib/iruby/kernel.rb:38:in `run'
/home/jovyan/.bundle/ruby/2.7.0/gems/iruby-0.4.0/lib/iruby/command.rb:110:in `run_kernel'
/home/jovyan/.bundle/ruby/2.7.0/gems/iruby-0.4.0/lib/iruby/command.rb:40:in `run'
/home/jovyan/.bundle/ruby/2.7.0/gems/iruby-0.4.0/bin/iruby:5:in `<top (required)>'
/home/jovyan/.gem/ruby/2.7.0/bin/iruby:23:in `load'
/home/jovyan/.gem/ruby/2.7.0/bin/iruby:23:in `<main>'
@mrkn mrkn added the bug label Jul 13, 2021
@mrkn mrkn self-assigned this Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants