pandas/plot-kind-argument
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| pandas | info | safe, with xpd check --fix |
All versions |
df.plot(kind="bar") hides the kind in a text argument. Call the accessor method, as in df.plot.bar(...), which draws the same figure.
df.plot(kind="bar", x="team", y="score")df.plot.bar(x="team", y="score")What the rule reports
Section titled “What the rule reports”The rule reports df.plot(kind="bar", ...) for the eleven kinds that the accessor has a method for: line, bar, barh, box, hist, kde, density, area, pie, scatter and hexbin. The two forms were equal as JSON with the plotly backend, and xpd reads the method form when pandas draws with plotly. The rule leaves alone a kind that only another backend knows, such as "violin" with plotly.
How to fix it
Section titled “How to fix it”xpd check --fix applies the fix of this rule.
The safe fix writes df.plot.bar(x="team", y="score").
Diagnostic message
Section titled “Diagnostic message”The plot accessor has a method for each kind. Write $X.plot.$KIND(...), which draws the same figure.See all rules in the pandas pack.