Title: plotly with pandas>=3.0 fails to raise name conflict error · Issue #4837 · plotly/plotly.py · GitHub
Open Graph Title: plotly with pandas>=3.0 fails to raise name conflict error · Issue #4837 · plotly/plotly.py
X Title: plotly with pandas>=3.0 fails to raise name conflict error · Issue #4837 · plotly/plotly.py
Description: import pandas as pd import plotly.express as px df = pd.DataFrame(dict(x=[0, 1], y=[1, 10], z=[0.1, 0.8], money=[100, 200])) df2 = pd.DataFrame(dict(time=[23, 26], money=[100, 200])) fig = px.scatter(df, x="z", y=df2.money, size=df.y) Wi...
Open Graph Description: import pandas as pd import plotly.express as px df = pd.DataFrame(dict(x=[0, 1], y=[1, 10], z=[0.1, 0.8], money=[100, 200])) df2 = pd.DataFrame(dict(time=[23, 26], money=[100, 200])) fig = px.scatt...
X Description: import pandas as pd import plotly.express as px df = pd.DataFrame(dict(x=[0, 1], y=[1, 10], z=[0.1, 0.8], money=[100, 200])) df2 = pd.DataFrame(dict(time=[23, 26], money=[100, 200])) fig = px.scatt...
Opengraph URL: https://github.com/plotly/plotly.py/issues/4837
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"plotly with pandas>=3.0 fails to raise name conflict error","articleBody":"```python\nimport pandas as pd\nimport plotly.express as px\ndf = pd.DataFrame(dict(x=[0, 1], y=[1, 10], z=[0.1, 0.8], money=[100, 200]))\ndf2 = pd.DataFrame(dict(time=[23, 26], money=[100, 200]))\nfig = px.scatter(df, x=\"z\", y=df2.money, size=df.y)\n```\n\nWith pandas 2.2.3:\n```python-traceback\nTraceback (most recent call last):\n File \"/home/marcogorelli/scratch/.venv/lib/python3.12/site-packages/marimo/_runtime/executor.py\", line 157, in execute_cell\n exec(cell.body, glbls)\n Cell marimo://trying_plotly.py#cell=cell-0\n, line 5, in \u003cmodule>\n fig = px.scatter(df, x=\"z\", y=df2.money, size=df.y)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/marcogorelli/scratch/.venv/lib/python3.12/site-packages/plotly/express/_chart_types.py\", line 66, in scatter\n return make_figure(args=locals(), constructor=go.Scatter)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/marcogorelli/scratch/.venv/lib/python3.12/site-packages/plotly/express/_core.py\", line 2117, in make_figure\n args = build_dataframe(args, constructor)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/marcogorelli/scratch/.venv/lib/python3.12/site-packages/plotly/express/_core.py\", line 1513, in build_dataframe\n df_output, wide_id_vars = process_args_into_dataframe(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/marcogorelli/scratch/.venv/lib/python3.12/site-packages/plotly/express/_core.py\", line 1271, in process_args_into_dataframe\n col_name = _check_name_not_reserved(field, reserved_names)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/marcogorelli/scratch/.venv/lib/python3.12/site-packages/plotly/express/_core.py\", line 1006, in _check_name_not_reserved\n raise NameError(\nNameError: A name conflict was encountered for argument 'y'. A column or index with name 'y' is ambiguous.\n```\n\nWith the latest pandas nightly (installable with `pip install --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple pandas`) it just plots, without raising\n\n\n\nThe difference is due to pandas no longer caching `__getitem__` for columns:\n\nin pandas 3.0+\n```python\nIn [1]: import pandas as pd\n\nIn [2]: df = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]})\n\nIn [3]: df['a'] is df['a']\nOut[3]: False\n````\n\nin pandas 2.2.3\n```python\nIn [1]: import pandas as pd\n\nIn [2]: df = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]})\n\nIn [3]: df['a'] is df['a']\nOut[3]: True\n```","author":{"url":"https://github.com/MarcoGorelli","@type":"Person","name":"MarcoGorelli"},"datePublished":"2024-10-28T09:47:23Z","url":"https://github.com/plotly/plotly.py/issues/4837"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cc1467d3-878f-45cb-1215-11c229130536 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C2F4:16AB79:FE96C6:14482BB:6B011207 |
| html-safe-nonce | dbca84e203be44f87b1df6732043fa7b4358dc3b938fa3a74d44576e1d978f5a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMkY0OjE2QUI3OTpGRTk2QzY6MTQ0ODJCQjo2QjAxMTIwNyIsInZpc2l0b3JfaWQiOiIyMzA3NjAxNjI0MDIyOTc5MDc5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e9cbfd45a5737dcf74f7af40bcf463541c3a0fe97a288cb89918d7b47b8233b9 |
| hovercard-subject-tag | issue:2617886748 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/plotly/plotly.py/4837/issue_layout |
| twitter:image | https://opengraph.githubassets.com/352db522645164764baf9ace5dc804a857cdcca30f4c46fdffef01dcf14a5543/plotly/plotly.py/issues/4837 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/352db522645164764baf9ace5dc804a857cdcca30f4c46fdffef01dcf14a5543/plotly/plotly.py/issues/4837 |
| og:image:alt | import pandas as pd import plotly.express as px df = pd.DataFrame(dict(x=[0, 1], y=[1, 10], z=[0.1, 0.8], money=[100, 200])) df2 = pd.DataFrame(dict(time=[23, 26], money=[100, 200])) fig = px.scatt... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MarcoGorelli |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-preview |
| go-import | github.com/plotly/plotly.py git https://github.com/plotly/plotly.py.git |
| octolytics-dimension-user_id | 5997976 |
| octolytics-dimension-user_login | plotly |
| octolytics-dimension-repository_id | 14579099 |
| octolytics-dimension-repository_nwo | plotly/plotly.py |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14579099 |
| octolytics-dimension-repository_network_root_nwo | plotly/plotly.py |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width