pandas/plot-kind-argument
| Rule | plot-kind-argument |
|---|---|
| Pack | pandas |
| Severity | info |
| Fix | safe, with xpd check --fix |
| Library versions | every version |
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").
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
The plot accessor has a method for each kind. Write $X.plot.$KIND(...), which draws the same figure.Browse the other rules of the pandas pack.