Pandas Dataframe.from_records has an Exclude
parameter:
exclude : sequence, default None Columns or fields to exclude
The logic for column exclusion can be found here.
Since for my specific use case, I'd like to exclude most of my columns, and would rather just specify which columns to include, I'd love to also see an Include parameter here.
Arbitrarily, if a field were both Included and Excluded it could be excluded (or throw an error).
Comment From: jreback
I suppose that is reasonable. Can you do a pull-request for this this?
we have similar logic in .select_dtypes
, so could follow that model.
Comment From: alexlenail
@miahunsicker It may be the case that the "columns" parameter actually does this, which would be unintuitive. My tests seem to indicate that's what it's doing.
Comment From: jreback
yeah, re-reading the description makes it clear that columns
is esentially include
, though it does also provides names
. In theory if one were writing this again, we would use the terms names
and usecols
, like read_csv
. But this ship has sailed.
I think what would be really useful here is to provide a set of examples that show the uses (in the doc-string).
up for that?