You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation specified that the columns kwarg is "Columns to write." If there is no matching column to write this would seem to warent an error of some kind. Instead an unrelated warning is printed.
The warning isn't technically unrelated - behind the scenes columns argument is getting passed to .loc, which now allows missing labels but in the future will raise a KeyError. This is xref #15747
Until that happens you could still get the desired outcome if selected the columns from the data frame directly
>>> data[['a', 'x']].to_csv()
KeyError: "['x'] not in index"
Closing as I don't think anything needs to change with to_csv for desired outcome here; will be a byproduct of a future change as directed in the FutureWarning
@WillAyd : I don't understand, on 1.0.x this still gives the very cryptic exception rather than the clear error message stating the wrong field. Are you saying the error message will be implemented, if so which milestone commitment? Can you add the commitment, or else reopen this? It is a real issue, until it's fixed.
Code Sample, a copy-pastable example if possible
Problem description
The documentation specified that the columns kwarg is "Columns to write." If there is no matching column to write this would seem to warent an error of some kind. Instead an unrelated warning is printed.
Expected Output
An exception should be thrown.
Output of
pd.show_versions()
In [6]: pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.7.3.final.0
python-bits: 64
OS: Darwin
OS-release: 16.7.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_CA.UTF-8
LOCALE: en_CA.UTF-8
pandas: 0.24.2
pytest: None
pip: 19.1
setuptools: 41.0.1
Cython: 0.29
numpy: 1.16.2
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 5.8.0
sphinx: None
patsy: None
dateutil: 2.7.5
pytz: 2018.7
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.2.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None
The text was updated successfully, but these errors were encountered: