You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
C:\Ruby34\bin>irb
irb(main):001> require 'pandas'
=> true
irb(main):002> df = Pandas.DataFrame.new([['a', 1], ['a', 1], ['b', 2]])
=>
0 1
...
irb(main):003* df.groupby(0).groups.each do |name, value|
irb(main):004* p name, value
irb(main):005> end
C:/Ruby34/lib/ruby/gems/3.4.0/gems/pycall-1.5.6/lib/pycall/dict.rb:38:in 'PyCall::LibPython::Helpers.dict_each': unexpected Python type PrettyDict (expected dict) (TypeError)
LibPython::Helpers.dict_each(__pyptr__, &block)
^^^^^^^^^
from C:/Ruby34/lib/ruby/gems/3.4.0/gems/pycall-1.5.6/lib/pycall/dict.rb:38:in 'PyCall::Dict#each'
from (irb):3:in '<main>'
from <internal:kernel>:168:in 'Kernel#loop'
from C:/Ruby34/lib/ruby/gems/3.4.0/gems/irb-1.14.3/exe/irb:9:in '<top (required)>'
from C:/Ruby34/bin/irb:33:in 'Kernel#load'
from C:/Ruby34/bin/irb:33:in '<main>'
irb(main):006>
While on python, the snippet works fine:
(base) C:\Windows\System32>python
Python 3.14.6 | packaged by Anaconda, Inc. | (main, Jul 9 2026, 14:29:05) [MSC v.1942 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>> df = pandas.DataFrame([['a', 1], ['a', 1], ['b', 2]])
>>> for name, value in df.groupby(0).groups.items():
... print(name, value)
...
a RangeIndex(start=0, stop=2, step=1)
b RangeIndex(start=2, stop=3, step=1)
>>>
> irb -Ilib -Iext/pycall
irb(main):001> require 'pandas'
=> true
irb(main):002> df = Pandas.DataFrame.new([['a', 1], ['a', 1], ['b', 2]])
=>
0 1
...
irb(main):003* df.groupby(0).groups.each do |name, value|
irb(main):004* p name, value
irb(main):005> end
"a"
RangeIndex(start=0, stop=2, step=1)
"b"
RangeIndex(start=2, stop=3, step=1)
=> {'a': [0, 1], 'b': [2]}
>python
Python 3.14.6 | packaged by Anaconda, Inc. | (main, Jul 9 2026, 14:29:05) [MSC v.1942 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>> df = pandas.DataFrame([['a', 1], ['a', 1], ['b', 2]])
>>> for name, value in df.groupby(0).groups.items():
... print(name, value)
...
a RangeIndex(start=0, stop=2, step=1)
b RangeIndex(start=2, stop=3, step=1)
>>>
Activity
felixmarch commentedon Nov 10, 2026
The reported issue is reproducible on my env:
While on python, the snippet works fine:
(my env is windows with anaconda)
felixmarch commentedon Nov 10, 2026
PR #237 raised
Support dict subclasses in PyCall::Dict#each and #has_key? (red-data-…
Support dict subclasses in PyCall::Dict#each and #has_key? (red-data-…