Skip to content

Commit ce05903

Browse files
authored
Fixed #1119 Pandas to NumPy array read-only error (#1120)
* Fixed #1119 Pandas to NumPy array read-only error * Updated docstrings
1 parent cc6546b commit ce05903

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

stumpy/core.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,8 +2117,9 @@ def _preprocess(T, copy=True):
21172117
Time series or sequence
21182118
21192119
copy : bool, default True
2120-
A boolean value that indicates whether the process should be done on
2121-
input `T` (False) or its copy (True).
2120+
A boolean value that indicates whether the process should be performed on
2121+
input array `T` (False) or its copy (True). If `T` is a dataframe, then the
2122+
data is always copied into a brand new array.
21222123
21232124
Returns
21242125
-------
@@ -2133,6 +2134,9 @@ def _preprocess(T, copy=True):
21332134

21342135
T = transpose_dataframe(T)
21352136

2137+
if "pandas" in str(type(T)):
2138+
T = T.to_numpy(copy=True)
2139+
21362140
if "polars" in str(type(T)):
21372141
T = T.to_numpy(writable=True)
21382142

@@ -2170,8 +2174,9 @@ def preprocess(
21702174
Window size
21712175
21722176
copy : bool, default True
2173-
A boolean value that indicates whether the process should be done on
2174-
input `T` (False) or its copy (True).
2177+
A boolean value that indicates whether the process should be performed on
2178+
input array `T` (False) or its copy (True). If `T` is a dataframe, then the
2179+
data is always copied into a brand new array.
21752180
21762181
M_T : numpy.ndarray, default None
21772182
Rolling mean
@@ -2233,8 +2238,9 @@ def preprocess_non_normalized(T, m, copy=True):
22332238
Window size
22342239
22352240
copy : bool, default True
2236-
A boolean value that indicates whether the process should be done on
2237-
input `T` (False) or its copy (True).
2241+
A boolean value that indicates whether the process should be performed on
2242+
input array `T` (False) or its copy (True). If `T` is a dataframe, then the
2243+
data is always copied into a brand new array.
22382244
22392245
Returns
22402246
-------
@@ -2293,8 +2299,9 @@ def preprocess_diagonal(
22932299
corresponding value set to False in this boolean array.
22942300
22952301
copy : bool, default True
2296-
A boolean value that indicates whether the process should be done on
2297-
input `T` (False) or its copy (True).
2302+
A boolean value that indicates whether the process should be performed on
2303+
input array `T` (False) or its copy (True). If `T` is a dataframe, then the
2304+
data is always copied into a brand new array.
22982305
22992306
Returns
23002307
-------

0 commit comments

Comments
 (0)