Skip to content

Commit 6676061

Browse files
committed
copy numpy array
1 parent 594ded0 commit 6676061

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

packages/python/plotly/plotly/express/trendline_functions/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,20 @@ def lowess(trendline_options, x_raw, x, y, x_label, y_label, non_missing):
111111

112112

113113
def _pandas(mode, trendline_options, x_raw, y, non_missing):
114+
import numpy as np
115+
116+
try:
117+
import pandas as pd
118+
except ImportError:
119+
msg = "Trendline requires pandas to be installed"
120+
raise ImportError(msg)
121+
114122
modes = dict(rolling="Rolling", ewm="Exponentially Weighted", expanding="Expanding")
115123
trendline_options = trendline_options.copy()
116124
function_name = trendline_options.pop("function", "mean")
117125
function_args = trendline_options.pop("function_args", dict())
118126

119-
pd = nw.dependencies.get_pandas()
120-
if pd is None:
121-
msg = "Trendline requires pandas to be installed"
122-
raise ImportError(msg)
123-
124-
series = pd.Series(y, index=x_raw.to_pandas())
127+
series = pd.Series(np.copy(y), index=x_raw.to_pandas())
125128

126129
# TODO: If narwhals were to support rolling, ewm and expanding then we could go around these
127130
agg = getattr(series, mode) # e.g. series.rolling

packages/python/plotly/plotly/figure_factory/_hexbin_mapbox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def create_hexbin_mapbox(
427427
agg_data_frame_list.append(
428428
nw.from_dict(
429429
{
430-
"frame": [int(key[0])] * len(hexagons_ids),
430+
"frame": [key[0]] * len(hexagons_ids),
431431
"locations": hexagons_ids,
432432
"color": aggregated_value,
433433
},

packages/python/plotly/plotly/tests/test_optional/test_figure_factory/test_figure_factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4474,7 +4474,7 @@ def test_build_dataframe(self):
44744474
lon = np.random.randn(N)
44754475
color = np.ones(N)
44764476
frame = np.random.randint(0, n_frames, N)
4477-
df = pd.DataFrame(
4477+
df = pd.DataFrame( # TODO: Test other constructors?
44784478
np.c_[lat, lon, color, frame],
44794479
columns=["Latitude", "Longitude", "Metric", "Frame"],
44804480
)

0 commit comments

Comments
 (0)