In a tool that I'm building that utilizes Pandas data frames, I'm adding a simple data validation layer to only accept numeric columns of a given data frame. I found a Stack Overflow question from a bit over a year ago pointing out the private _get_numeric_data() method in the DataFrame class. Would it be possible to make this method part of the public API?
(And my apologies if this request has been made before; I did a few searches through the issues and didn't find anything.)
Could you write a function that filters based on the dtypes property?
Shouldn't be too difficult and lets you customize what you want to get.
I think this would be a pretty limited use case, so I'd prefer not to
expand the public API for this.
feel free to submit a function to say the cookbook for dtype filtering
I find myself implementing this functionality over and over again. FWIW, I think having a public API for get_dtype would be super useful where it's more general than just a filter. Ie., get numeric types, get object types, get categorical types. Or even get numeric, object, date, or categorical column names.
I suppose is not advertised that much
!
How have I never noticed this? Cross-linking. This is more or less addressed in #7434.
Most helpful comment
http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.select_dtypes.html?highlight=dtypes#pandas.DataFrame.select_dtypes
I suppose is not advertised that much