-
Notifications
You must be signed in to change notification settings - Fork 339
Closed
Description
Summary
As reported in this comment, some tests are failing.
The error shows:
# in core.preprocess_non_normalized
T[~np.isfinite(T)] = np.nan
^^^^^^^^^^^^^^^^^^
E ValueError: assignment destination is read-only
This error occurs because the array T that is returned by the following line of the function core.preprocess_non_normalized is read-only when its input is pandas.Series.
Line 2248 in cc6546b
| T = _preprocess(T, copy) |
Minimum Reproducible Example:
import pandas as pd
import numpy as np
print(pd.__version__) # 3.0.0
print(np.__version__) # 2.3.5
T_B = np.array([ 584., -11., 23., 79., 1001., 0., -19.])
ps = pd.Series(T_B)
T = np.asarray(ps)
T[0] = 100
# Error
# ValueError: assignment destination is read-only
Investigation
Further investigation shows that np.shares_memory(T, ps.array) returns True for the example above, and according to read-only array section in pandas Copy-on-Write (CoW):
Accessing the underlying NumPy array of a DataFrame will return a read-only array if the array shares data with the initial DataFrame:
seanlaw
Metadata
Metadata
Assignees
Labels
No labels