Pandas excel output specify column names to write is broken in 1.0.0 #31677
Labels
Bug
IO Excel
read_excel, to_excel
Regression
Functionality that used to work in a prior pandas version
Milestone
Example code:
df = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),columns=['col_a', 'col_b', 'col_c'])
excelwritename = '/tmp/Test%s.xlsx' %pd.datetime.now(pytz.timezone('US/Pacific')).strftime('%b%d_%I_%M %p')
with pd.ExcelWriter(excelwritename, engine='xlsxwriter',datetime_format='mmm dd yyyy hh:mm AM/PM') as writer:
df.to_excel(writer,columns=['col_a','col_b'],sheet_name = 'xyz')
Problem description:
specifying column names to output to excel is no longer working in pandas 1.0.0 and it outputs all columns in the df.
Checked different versions of xlsxwriter, but pandas 0.25.3 works fine, while 1.0.0 does not.
Expected Output
It should only output columns that are specified, but it outputs all columns of df
Output of
pd.show_versions()
[paste the output of
pd.show_versions()
here below this line]INSTALLED VERSIONS
commit : None
python : 3.7.4.final.0
python-bits : 64
OS : Darwin
OS-release : 19.2.0
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.0.0
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 45.1.0.post20200127
Cython : 0.29.14
pytest : 5.3.4
hypothesis : 4.54.2
sphinx : 2.3.1
blosc : None
feather : None
xlsxwriter : 1.2.0
lxml.etree : 4.4.2
html5lib : 1.0.1
pymysql : None
psycopg2 : 2.8.4 (dt dec pq3 ext lo64)
jinja2 : 2.10.3
IPython : 7.11.1
pandas_datareader: None
bs4 : 4.8.2
bottleneck : 1.3.1
fastparquet : None
gcsfs : None
lxml.etree : 4.4.2
matplotlib : 3.1.1
numexpr : 2.7.0
odfpy : None
openpyxl : 3.0.3
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.3.4
pyxlsb : None
s3fs : None
scipy : 1.3.1
sqlalchemy : 1.3.13
tables : 3.6.1
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : 1.3.0
xlsxwriter : 1.2.0
numba : 0.48.0
The text was updated successfully, but these errors were encountered: