Description
Feature Type
-
Adding new functionality to pandas
-
Changing existing functionality in pandas
-
Removing existing functionality in pandas
Problem Description
When using matplotlib
as the backend, pandas.DataFrame.hist()
only supports plotting for numeric and datetype data,
pandas/pandas/plotting/_matplotlib/hist.py
Lines 464 to 512 in 5cf5c73
whereas matplotlib.axes.Axes.hist()
and pandas.Series.hist()
support a wider range of data types. We can consider allowing users to specify the numeric_only
parameter to determine whether to plot only numeric columns or all columns in the chart.
For reproducing:
import pandas as pd
import numpy as np
df = pd.DataFrame(dict(a=np.random.normal(size=100), b=np.random.normal(size=100)+100, c=np.random.choice(['A', 'B'], size=100), d=np.random.choice(['C', 'D'], size=100)))
df['d'].hist() # <AxesSubplot: title={'center': 'b'}>
df.hist() # array([[<AxesSubplot: title={'center': 'a'}>, <AxesSubplot: title={'center': 'b'}>]], dtype=object)
Besides, the title for the histogram of df['d'].hist()
is wrong and it could be fixed in my PR for issue #53281
I have completed a draft implementation, and if necessary, I can create a pull request.
Feature Description
Allowing plotting for a wider range of datatypes in DataFrame.hist
Alternative Solutions
Haven't found one.
Additional Context
No response