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

get_mps not compatible with Pandas copy_on_write mode #3

Open
matthew-brett opened this issue May 20, 2024 · 0 comments
Open

get_mps not compatible with Pandas copy_on_write mode #3

matthew-brett opened this issue May 20, 2024 · 0 comments

Comments

@matthew-brett
Copy link

matthew-brett commented May 20, 2024

Thanks for this package!

I nearly always use Pandas copy_on_write mode - which will be the default and only mode in upcoming Pandas 3.0 : https://pandas.pydata.org/pandas-docs/stable//user_guide/copy_on_write.html.

I enable it with:

pd.set_option('mode.copy_on_write', True)

However, it looks like this causes some internal problems for pdpy. When I do pdpy.fetch_mps with a date range, before enabling that option, all goes well:

import pdpy

# No error, a data frame results.
pdpy.fetch_mps(from_date='2000-10-11',to_date='2024-02-19')

However, if I enable copy_on_write, I get an error:

pd.set_option('mode.copy_on_write', True)
pdpy.fetch_mps(from_date='2000-10-11',to_date='2024-02-19')

This results in:

File ~/Library/Python/3.11/lib/python/site-packages/pdpy/mps.py:241, in fetch_commons_memberships(from_date, to_date, on_date)
    238         election = general_elections[j, 2]
    240         if date > dissolution and date <= election:
--> 241             end_dates[i] = dissolution
    242             continue
    244 commons_memberships['seat_incumbency_end_date'] = end_dates

ValueError: assignment destination is read-only

Is there something going in internally that does not work with this option?

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

No branches or pull requests

1 participant