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

Pandas concat cannot take an ImmutableDict #71

Open
berquist opened this issue Nov 26, 2019 · 2 comments
Open

Pandas concat cannot take an ImmutableDict #71

berquist opened this issue Nov 26, 2019 · 2 comments

Comments

@berquist
Copy link
Member

>>> pd.concat(scores_per_document)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/berquist/.anaconda/envs/event-extraction-3.6/lib/python3.6/site-packages/pandas/core/reshape/concat.py", line 255, in concat
    sort=sort,
  File "/Users/berquist/.anaconda/envs/event-extraction-3.6/lib/python3.6/site-packages/pandas/core/reshape/concat.py", line 332, in __init__
    raise TypeError(msg)
TypeError: cannot concatenate object of type '<class 'str'>'; only Series and DataFrame objs are valid
>>> type(scores_per_document)
immutablecollections._immutabledict.RegularDictBackedImmutableDict
>>> type(dict(scores_per_document))
<class 'dict'>
>>> pd.concat(dict(scores_per_document))
                                                              tp   fp   fn  precision  recall     f1
AFP_ENG_20030323.0020              Personnel.Start-Position  0.0  0.0  0.0        0.0     0.0    0.0
                                   Personnel.End-Position    0.0  0.0  0.0        0.0     0.0    0.0
                                   Personnel.Nominate        0.0  0.0  0.0        0.0     0.0    0.0
                                   Personnel.Elect           0.0  0.0  0.0        0.0     0.0    0.0
                                   Movement.Transport        3.0  0.0  0.0      100.0   100.0  100.0
...                                                          ...  ...  ...        ...     ...    ...
AGGRESSIVEVOICEDAILY_20050124.1354 Justice.Execute           0.0  0.0  0.0        0.0     0.0    0.0
                                   Justice.Extradite         0.0  0.0  0.0        0.0     0.0    0.0
                                   Justice.Appeal            0.0  0.0  0.0        0.0     0.0    0.0
                                   Justice.Pardon            0.0  0.0  0.0        0.0     0.0    0.0
                                   __ALL_EVENTS_COMBINED__   2.0  0.0  0.0      100.0   100.0  100.0

[660 rows x 6 columns]
@gabbard
Copy link

gabbard commented Dec 2, 2019

@berquist : I don't think this is something we can do anything about. The problem is here: https://github.com/pandas-dev/pandas/blob/83812e1ba93b7857b8222e6651c823a88223472f/pandas/core/reshape/concat.py#L293 . You could file an issue+PR with pandas requesting it become isinstance(objs, Mapping).

@gabbard
Copy link

gabbard commented Feb 4, 2020

There is a Pandas issue corresponding to this: pandas-dev/pandas#6792

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants