Skip to content

Add support for pandas>=3#1698

Merged
maartenbreddels merged 2 commits into
bqplot:masterfrom
bmorris3:pandas3
Apr 27, 2026
Merged

Add support for pandas>=3#1698
maartenbreddels merged 2 commits into
bqplot:masterfrom
bmorris3:pandas3

Conversation

@bmorris3

@bmorris3 bmorris3 commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

This PR adds support for pandas>=3. I'll leave inline comments in the diff to explain changes.

References

This PR is a follow-up to #1692.

Closes #1691

Code changes

User-facing changes

Backwards-incompatible changes

Comment thread bqplot/traits.py
Comment on lines +109 to +118
elem, errors='coerce')
temp_val = elem if isinstance(temp_val[0], type(pd.NaT)) else temp_val
return_value.append(temp_val)
elif isinstance(array, list):
temp_val = pd.to_datetime(
array, errors='coerce', infer_datetime_format=True)
array, errors='coerce')
return_value = array if isinstance(temp_val[0], type(pd.NaT)) else temp_val
else:
temp_val = pd.to_datetime(
array, errors='coerce', infer_datetime_format=True)
array, errors='coerce')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The kwarg infer_datetime_format was deprecated in pandas 2.0; see changelog, pandas-dev/pandas#48621. The behavior since v2 is equivalent to infer_datetime_format=True.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a condition here for the pandas version being used? Otherwise I guess we'd be breaking datetimes handling for pandas <2?

Comment on lines 58 to 86
@@ -81,7 +81,7 @@
"axes_options = {\"y\": {\"tick_format\": \",\"}}\n",
"time_series = plt.plot(dates, prices, colors=[\"deepskyblue\"], \n",
" stroke_width=1.5, axes_options=axes_options)\n",
"return_label = plt.label([], x=[], y=[prices.max() * .9], \n",
"return_label = plt.label([], x=[], y=[prices.max().squeeze() * .9], \n",
" align=\"middle\", default_size=36, \n",
" font_weight=\"bolder\", colors=[\"orange\"])\n",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The squeeze kwarg has been deprecated since v1.4; see changelog, pandas-dev/pandas#43242.

"\n",
"log_data.index = pd.to_datetime(\n",
" log_data[\"timestamp\"].str.replace(\"[\\[\\]]\", \"\"), format=\"%d/%b/%Y:%H:%M:%S\"\n",
" log_data[\"timestamp\"].str.replace(\"[\", '').str.replace(\"]\", ''), \n",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex wasn't working in my tests with pandas 3.0, so I replaced it with a longer and equivalent call.

Comment on lines 29 to +50
@@ -46,8 +47,16 @@
"metadata": {},
"outputs": [],
"source": [
"sel.selected = 5"
"sel.selected = np.array([5])"

@bmorris3 bmorris3 Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that bqplot fails when the selected attribute is set with a float/int rather a numpy array. Is that expected?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's strange/unexpected @copilot can you turn this into an issue to track this?

Comment thread test-environment.yml
- flake8
- nose
- codespell
- scikit-learn

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used by the tests but not required in the test-env.

@maartenbreddels

Copy link
Copy Markdown
Member

please update snapshots

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@maartenbreddels maartenbreddels merged commit 6f3f145 into bqplot:master Apr 27, 2026
10 checks passed
@maartenbreddels

Copy link
Copy Markdown
Member

@meeseeksdev backport to 0.12.x

maartenbreddels added a commit to meeseeksmachine/bqplot that referenced this pull request Apr 27, 2026
martinRenou pushed a commit that referenced this pull request Apr 27, 2026
Co-authored-by: Maarten Breddels <maartenbreddels@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pandas 3 support

3 participants