We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
df1 = pd.DataFrame.from_records([[1,2,3],[4,5,6],[7,8,9]], index=0, exclude=[0]) df2 = pd.DataFrame.from_records([[1,2,3],[4,5,6],[7,8,9]], index=0)
In both cases, the data frame has columns 0, 1 and 2. If you use an index of 1, or exclude=[1], the columns are (correctly) [0, 2].
exclude=[1]
[0, 2]
The issue is caused by the any() call at https://github.com/pandas-dev/pandas/blob/master/pandas/core/frame.py#L1178 which treats a zero column ID as false. Changing this to if exclude fixes the problem for me (by running the code to drop columns if the exclude set is not empty).
any()
if exclude
pd.show_versions()
pandas: 0.21.0 pytest: None pip: 9.0.1 setuptools: 38.2.4 Cython: None numpy: 1.13.3 scipy: None pyarrow: None xarray: None IPython: 6.2.1 sphinx: None patsy: None dateutil: 2.6.1 pytz: 2017.3 blosc: None bottleneck: None tables: None numexpr: None feather: None matplotlib: 2.1.0 openpyxl: 2.4.9 xlrd: None xlwt: None xlsxwriter: None lxml: None bs4: None html5lib: 1.0b10 sqlalchemy: None pymysql: None psycopg2: None jinja2: 2.10 s3fs: None fastparquet: None pandas_gbq: None pandas_datareader: None
The text was updated successfully, but these errors were encountered:
still an issue
Sorry, something went wrong.
Still open, if you're interested in submitting a PR @OmerJog.
No branches or pull requests
Code Sample, a copy-pastable example if possible
Problem description
In both cases, the data frame has columns 0, 1 and 2. If you use an index of 1, or
exclude=[1]
, the columns are (correctly)[0, 2]
.The issue is caused by the
any()
call at https://github.com/pandas-dev/pandas/blob/master/pandas/core/frame.py#L1178 which treats a zero column ID as false. Changing this toif exclude
fixes the problem for me (by running the code to drop columns if the exclude set is not empty).Output of
pd.show_versions()
pandas: 0.21.0
pytest: None
pip: 9.0.1
setuptools: 38.2.4
Cython: None
numpy: 1.13.3
scipy: None
pyarrow: None
xarray: None
IPython: 6.2.1
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.1.0
openpyxl: 2.4.9
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 1.0b10
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: