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

model.biplot() error when pd.options.mode.copy_on_write = True #49

Open
FlorinAndrei opened this issue Jul 6, 2023 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@FlorinAndrei
Copy link

Python 3.11.4
Pandas 2.0.3
pca 2.0.3

Code:

from sklearn.datasets import load_wine
import pandas as pd
from pca import pca

pd.options.mode.copy_on_write = True

data = load_wine()
df = pd.DataFrame(index=data.target, data=data.data, columns=data.feature_names)
model = pca(normalize=True, detect_outliers=['ht2', 'spe'], n_std=2)
results = model.fit_transform(df)

model.biplot(SPE=False, HT2=True, density=True)

Results:

ValueError: assignment destination is read-only

Fixed code (no errors):

pd.options.mode.copy_on_write = False
model.biplot(SPE=False, HT2=True, density=True)
pd.options.mode.copy_on_write = True
@erdogant
Copy link
Owner

erdogant commented Aug 5, 2023

Thank you for mentioning this! I have not seen this error before. Does this happen because your machine (or server) does not have writing rights to disk?

@erdogant erdogant added the enhancement New feature or request label Aug 5, 2023
@FlorinAndrei
Copy link
Author

No, there are several libraries impacted by this bug. Perhaps your library is just triggering it in a downstream library, I'm not sure.

Anyway, pd.options.mode.copy_on_write = True seems to trigger some kind of bug in Seaborn and other libs. I am simply reporting it where I see it. Copy on write is a very useful feature, recently introduced in Pandas, and I would prefer to be able to keep it enabled without having issues with various libraries out there.

@erdogant
Copy link
Owner

erdogant commented Aug 7, 2023

Good to know! Thanks!

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

No branches or pull requests

2 participants