Skip to content

Commit d844cdd

Browse files
committed
update dependencies and various code updates
1 parent 589b30b commit d844cdd

10 files changed

+48
-43
lines changed

binder/requirements.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ jupytext
22
plotly==5.21.0
33
jupyter
44
notebook
5-
pandas==1.2.0
6-
statsmodels==0.12.1
5+
pandas==2.2.2
6+
statsmodels==0.14.2
77
scipy
8-
patsy==0.5.1
8+
patsy==0.5.6
99
numpy
1010
plotly-geo
1111
psutil

doc/python/3d-volume.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ np.random.seed(0)
8686
l = 30
8787
X, Y, Z = np.mgrid[:l, :l, :l]
8888
vol = np.zeros((l, l, l))
89-
pts = (l * np.random.rand(3, 15)).astype(np.int)
89+
pts = (l * np.random.rand(3, 15)).astype(int)
9090
vol[tuple(indices for indices in pts)] = 1
9191
from scipy import ndimage
9292
vol = ndimage.gaussian_filter(vol, 4)

doc/python/axes.md

+14-10
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ fig.show()
367367

368368
*New in 5.19*
369369

370-
If `tickangle` is not explicitly set, its default value is `auto`, meaning if the label needs to be rotated to avoid labels overlapping, it will rotate by either 30 or 90 degrees. Using `autotickangles`, you can also specify a list of angles for `tickangle` to use. If `tickangle` is `auto` and you provide a list of angles to `autotickangles`, the label angle will be set to the first value in the list that prevents overlap.
370+
If `tickangle` is not explicitly set, its default value is `auto`, meaning if the label needs to be rotated to avoid labels overlapping, it will rotate by either 30 or 90 degrees. Using `autotickangles`, you can also specify a list of angles for `tickangle` to use. If `tickangle` is `auto` and you provide a list of angles to `autotickangles`, the label angle will be set to the first value in the list that prevents overlap.
371371

372372
```python
373373
import plotly.express as px
@@ -390,14 +390,18 @@ Here is an example.
390390
import plotly.graph_objects as go
391391
import pandas as pd
392392

393-
# Load and filter Apple stock data for 2016
394393
apple_df = pd.read_csv(
395-
"https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv",
396-
parse_dates=["Date"],
397-
index_col="Date"
394+
"https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv"
398395
)
399396

400-
apple_df_2016 = apple_df["2016"]
397+
# Convert 'Date' column to datetime format
398+
apple_df['Date'] = pd.to_datetime(apple_df['Date'])
399+
400+
# Set 'Date' column as index
401+
apple_df.set_index('Date', inplace=True)
402+
403+
# Filter for 2016
404+
apple_df_2016 = apple_df.loc['2016']
401405

402406
# Create figure and add line
403407
fig = go.Figure()
@@ -599,7 +603,7 @@ fig.show()
599603

600604
*New in 5.17*
601605

602-
You can also set just a lower or upper bound manually and have autorange applied to the other bound by setting it to `None`. In the following example, we set a an upper bound of 4.5 on the x axes, while specifying `None` for the lower bound, meaning it will use autorange. On the y axes, we set the lower bound, and use `None` for the upper bound, meaning that uses autorange.
606+
You can also set just a lower or upper bound manually and have autorange applied to the other bound by setting it to `None`. In the following example, we set a an upper bound of 4.5 on the x axes, while specifying `None` for the lower bound, meaning it will use autorange. On the y axes, we set the lower bound, and use `None` for the upper bound, meaning that uses autorange.
603607

604608
```python
605609
import plotly.express as px
@@ -857,7 +861,7 @@ fig.show()
857861

858862
#### <code>nonnegative</code>, <code>tozero</code>, and <code>normal</code> Rangemode
859863

860-
When you don't specify a range, autorange is used. It's also used for bounds set to `None` when providing a `range`.
864+
When you don't specify a range, autorange is used. It's also used for bounds set to `None` when providing a `range`.
861865

862866
The axis auto-range calculation logic can be configured using the `rangemode` axis parameter.
863867

@@ -898,7 +902,7 @@ fig.update_xaxes(autorangeoptions=dict(maxallowed=5))
898902
fig.show()
899903
```
900904

901-
##### Clip Minimum and Maximum
905+
##### Clip Minimum and Maximum
902906

903907
You can also clip an axis range at a specific maximum or minimum value with `autorangeoptions.clipmax` and `autorangeoptions.clipmin`.
904908

@@ -916,7 +920,7 @@ fig.show()
916920

917921
##### Specify Values to be Included
918922

919-
Use `autorangeoptions.include` to specify a value that should always be included within the calculated autorange. In this example, we specify that for the autorange calculated on the x-axis, 5 should be included.
923+
Use `autorangeoptions.include` to specify a value that should always be included within the calculated autorange. In this example, we specify that for the autorange calculated on the x-axis, 5 should be included.
920924

921925
```python
922926
import plotly.express as px

doc/python/box-plots.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,12 @@ x_data = ['Carmelo Anthony', 'Dwyane Wade',
458458

459459
N = 50
460460

461-
y0 = (10 * np.random.randn(N) + 30).astype(np.int)
462-
y1 = (13 * np.random.randn(N) + 38).astype(np.int)
463-
y2 = (11 * np.random.randn(N) + 33).astype(np.int)
464-
y3 = (9 * np.random.randn(N) + 36).astype(np.int)
465-
y4 = (15 * np.random.randn(N) + 31).astype(np.int)
466-
y5 = (12 * np.random.randn(N) + 40).astype(np.int)
461+
y0 = (10 * np.random.randn(N) + 30).astype(int)
462+
y1 = (13 * np.random.randn(N) + 38).astype(int)
463+
y2 = (11 * np.random.randn(N) + 33).astype(int)
464+
y3 = (9 * np.random.randn(N) + 36).astype(int)
465+
y4 = (15 * np.random.randn(N) + 31).astype(int)
466+
y5 = (12 * np.random.randn(N) + 40).astype(int)
467467

468468
y_data = [y0, y1, y2, y3, y4, y5]
469469

doc/python/icicle-charts.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def build_hierarchical_dataframe(df, levels, value_column, color_columns=None):
305305
Levels are given starting from the bottom to the top of the hierarchy,
306306
ie the last level corresponds to the root.
307307
"""
308-
df_all_trees = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
308+
df_trees = []
309309
for i, level in enumerate(levels):
310310
df_tree = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
311311
dfg = df.groupby(levels[i:]).sum()
@@ -317,11 +317,12 @@ def build_hierarchical_dataframe(df, levels, value_column, color_columns=None):
317317
df_tree['parent'] = 'total'
318318
df_tree['value'] = dfg[value_column]
319319
df_tree['color'] = dfg[color_columns[0]] / dfg[color_columns[1]]
320-
df_all_trees = df_all_trees.append(df_tree, ignore_index=True)
320+
df_trees.append(df_tree)
321321
total = pd.Series(dict(id='total', parent='',
322322
value=df[value_column].sum(),
323-
color=df[color_columns[0]].sum() / df[color_columns[1]].sum()))
324-
df_all_trees = df_all_trees.append(total, ignore_index=True)
323+
color=df[color_columns[0]].sum() / df[color_columns[1]].sum()), name=0)
324+
df_trees.append(total)
325+
df_all_trees = pd.concat(df_trees, ignore_index=True)
325326
return df_all_trees
326327

327328

doc/python/mixed-subplots.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ df = pd.read_csv(
5555
)
5656

5757
# frequency of Country
58-
freq = df
59-
freq = freq.Country.value_counts().reset_index().rename(columns={"index": "x"})
58+
freq = df['Country'].value_counts().reset_index()
59+
freq.columns = ['x', 'Country']
6060

6161
# read in 3d volcano surface data
6262
df_v = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/volcano.csv")

doc/python/ml-regression.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ from sklearn.linear_model import LinearRegression
120120
from sklearn.model_selection import train_test_split
121121

122122
df = px.data.tips()
123-
X = df.total_bill[:, None]
123+
X = df.total_bill.to_numpy()[:, None]
124124
X_train, X_test, y_train, y_test = train_test_split(X, df.tip, random_state=0)
125125

126126
model = LinearRegression()
@@ -129,7 +129,6 @@ model.fit(X_train, y_train)
129129
x_range = np.linspace(X.min(), X.max(), 100)
130130
y_range = model.predict(x_range.reshape(-1, 1))
131131

132-
133132
fig = go.Figure([
134133
go.Scatter(x=X_train.squeeze(), y=y_train, name='train', mode='markers'),
135134
go.Scatter(x=X_test.squeeze(), y=y_test, name='test', mode='markers'),

doc/python/sunburst-charts.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def build_hierarchical_dataframe(df, levels, value_column, color_columns=None):
355355
Levels are given starting from the bottom to the top of the hierarchy,
356356
ie the last level corresponds to the root.
357357
"""
358-
df_all_trees = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
358+
df_trees = []
359359
for i, level in enumerate(levels):
360360
df_tree = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
361361
dfg = df.groupby(levels[i:]).sum()
@@ -367,11 +367,12 @@ def build_hierarchical_dataframe(df, levels, value_column, color_columns=None):
367367
df_tree['parent'] = 'total'
368368
df_tree['value'] = dfg[value_column]
369369
df_tree['color'] = dfg[color_columns[0]] / dfg[color_columns[1]]
370-
df_all_trees = df_all_trees.append(df_tree, ignore_index=True)
370+
df_trees.append(df_tree)
371371
total = pd.Series(dict(id='total', parent='',
372372
value=df[value_column].sum(),
373-
color=df[color_columns[0]].sum() / df[color_columns[1]].sum()))
374-
df_all_trees = df_all_trees.append(total, ignore_index=True)
373+
color=df[color_columns[0]].sum() / df[color_columns[1]].sum()), name=0)
374+
df_trees.append(total)
375+
df_all_trees = pd.concat(df_trees, ignore_index=True)
375376
return df_all_trees
376377

377378

doc/python/treemaps.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ When the argument of `color` corresponds to non-numerical data, discrete colors
9090
```python
9191
import plotly.express as px
9292
df = px.data.tips()
93-
fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
93+
fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
9494
values='total_bill', color='day')
9595
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
9696
fig.show()
@@ -101,7 +101,7 @@ In the example below the color of Saturday and Sunday sectors is the same as Din
101101
```python
102102
import plotly.express as px
103103
df = px.data.tips()
104-
fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
104+
fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
105105
values='total_bill', color='time')
106106
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
107107
fig.show()
@@ -114,7 +114,7 @@ For more information about discrete colors, see the [dedicated page](/python/dis
114114
```python
115115
import plotly.express as px
116116
df = px.data.tips()
117-
fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
117+
fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
118118
values='total_bill', color='time',
119119
color_discrete_map={'(?)':'lightgrey', 'Lunch':'gold', 'Dinner':'darkblue'})
120120
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
@@ -241,7 +241,7 @@ fig = go.Figure(go.Treemap(
241241
labels = labels,
242242
values = values,
243243
parents = parents,
244-
marker_colors = ["pink", "royalblue", "lightgray", "purple",
244+
marker_colors = ["pink", "royalblue", "lightgray", "purple",
245245
"cyan", "lightgray", "lightblue", "lightgreen"]
246246
))
247247

@@ -316,7 +316,7 @@ def build_hierarchical_dataframe(df, levels, value_column, color_columns=None):
316316
Levels are given starting from the bottom to the top of the hierarchy,
317317
ie the last level corresponds to the root.
318318
"""
319-
df_all_trees = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
319+
df_trees = []
320320
for i, level in enumerate(levels):
321321
df_tree = pd.DataFrame(columns=['id', 'parent', 'value', 'color'])
322322
dfg = df.groupby(levels[i:]).sum()
@@ -328,11 +328,12 @@ def build_hierarchical_dataframe(df, levels, value_column, color_columns=None):
328328
df_tree['parent'] = 'total'
329329
df_tree['value'] = dfg[value_column]
330330
df_tree['color'] = dfg[color_columns[0]] / dfg[color_columns[1]]
331-
df_all_trees = df_all_trees.append(df_tree, ignore_index=True)
331+
df_trees.append(df_tree)
332332
total = pd.Series(dict(id='total', parent='',
333333
value=df[value_column].sum(),
334-
color=df[color_columns[0]].sum() / df[color_columns[1]].sum()))
335-
df_all_trees = df_all_trees.append(total, ignore_index=True)
334+
color=df[color_columns[0]].sum() / df[color_columns[1]].sum()), name=0)
335+
df_trees.append(total)
336+
df_all_trees = pd.concat(df_trees, ignore_index=True)
336337
return df_all_trees
337338

338339

doc/requirements.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ sphinx_bootstrap_theme
3131
recommonmark
3232
pathlib
3333
python-frontmatter
34-
datashader==0.14.4
34+
datashader==0.16.1
3535
pyarrow
3636
cufflinks==0.17.3
3737
kaleido
@@ -42,6 +42,5 @@ nbconvert==5.6.1
4242
orjson
4343
dash-bio
4444
jinja2<3.1
45-
parmed<=3.4.4; python_version<"3.8"
46-
dask==2022.2.0
45+
dask==2024.4.2
4746
polars

0 commit comments

Comments
 (0)