Skip to content

Conversation

@blu3-bird
Copy link

Fix: Replace cufflinks with plotly.express for Python 3.13+ compatibility

Problem

The current codebase uses the cufflinks library which is no longer actively maintained and causes compatibility issues with Python 3.13 and newer versions of pandas (2.x). This results in a ValueError when attempting to generate plots, preventing learners from running the code successfully.

Solution

This PR migrates all plotting functionality from cufflinks to plotly.express, which is:

  • Actively maintained by the Plotly team
  • Fully compatible with Python 3.13 and pandas 2.x

Changes Made

Code Changes:

  • Removed cufflinks and IPython.display imports
  • Added plotly.express
  • Converted all .iplot() calls to their plotly.express equivalents:
    • Line plots: df.iplot(kind='line')px.line(df)
    • Bar plots: df.iplot(kind='bar')px.bar(df)
    • Pie charts: df.iplot(kind='pie')px.pie(df)
    • Box plots: df.iplot(kind='box')px.box(df)
    • Histograms: df.iplot(kind='hist')px.histogram(df)
    • Scatter plots: df.iplot(kind='scatter')px.scatter(df)
  • Updated parameter names to match plotly.express conventions

Parameter Mapping:

  • xTitle and yTitlelabels dictionary
  • binsnbins
  • labels (in pie charts) → names

Installation Requirements

Since there is no requirements.txt file in the repository, users will need to install the required packages manually:

pip install pandas plotly

Testing

Tested on Python 3.13 with pandas 2.2.1 and plotly 5.x. All plots render correctly.

Fix issues #5

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.

1 participant