dict(df.groupby(...)) raises TypeError: 'str' object is not callable unexpectedly · Issue #136260 · python/cpython · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

dict(df.groupby(...)) raises TypeError: 'str' object is not callable unexpectedly #136260

Closed as not planned
@kay-ou

Description

@kay-ou

Bug report

Bug description:

When using the built-in dict() constructor on a pandas.DataFrameGroupBy object, Python raises the following error:

TypeError: 'str' object is not callable
This happens despite the following confirmations:

dict is <class 'type'> and not overwritten

df.groupby('security') yields valid (str, DataFrame) pairs

{k: v for k, v in df.groupby(...)} works as expected

dict([('a', 1), ('b', 2)]) works as expected

Error persists even in fresh Poetry virtual environments and minimal isolated scripts

import pandas as pd

df = pd.DataFrame({
    'security': ['A', 'B'],
    'price': [1, 2]
})

print(dict(df.groupby('security')))

Expected output:

{
    'A': pd.DataFrame(...),
    'B': pd.DataFrame(...)
}

Actual output:
TypeError: 'str' object is not callable

Item Value
Python version 3.12.3
OS Ubuntu 22.04
pandas version 2.3.0
Install method poetry
Reproduced in venv Yes
Reproduced in CLI Yes

Additional Notes

  • No local or global shadowing of dict
  • Running type(dict) returns <class 'type'>
  • Running dict is builtins.dict returns True
  • Minimal reproduction still fails with same error
  • Appears to be interpreter-level misinterpretation of built-in symbol

I’ve run integrity checks, deleted caches, and rebuilt environments—all to no avail. Let me know if I can help isolate it further or dig into Python internals!

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      TMZ Celebrity News – Breaking Stories, Videos & Gossip

      Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

      Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

      🎥 Watch TMZ Live

      TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.