-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: writing dataframe to excel if one of the rows has name "render" fails #34331
New issue
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
Comments
I tested your example on master and got a different traceback
You have a small error in your example, You have to exchange the first
|
5 tasks
Correct, sorry made a copy and paste error into the bug report.
should be
s1 = pd.Series(("1","2"),index=["a","b"])
s2 = pd.Series(("3","4"),index=["a","b"])
to reproduce the error.
… Am 23.05.2020 um 11:26 schrieb patrick ***@***.*** ***@***.***>>:
I tested your example on master and got a different traceback
Traceback (most recent call last):
File "/home/developer/.config/JetBrains/PyCharmCE2020.1/scratches/scratch_pandas.py", line 7, in <module>
df = pd.DataFrame({"render":s1,"huhu":s2})
File "/home/developer/PycharmProjects/pandas/pandas/core/frame.py", line 460, in __init__
mgr = init_dict(data, index, columns, dtype=dtype)
File "/home/developer/PycharmProjects/pandas/pandas/core/internals/construction.py", line 283, in init_dict
return arrays_to_mgr(arrays, data_names, index, columns, dtype=dtype)
File "/home/developer/PycharmProjects/pandas/pandas/core/internals/construction.py", line 83, in arrays_to_mgr
arrays = _homogenize(arrays, index, dtype)
File "/home/developer/PycharmProjects/pandas/pandas/core/internals/construction.py", line 340, in _homogenize
val = val.reindex(index, copy=False)
File "/home/developer/PycharmProjects/pandas/pandas/core/series.py", line 4204, in reindex
return super().reindex(index=index, **kwargs)
File "/home/developer/PycharmProjects/pandas/pandas/core/generic.py", line 4482, in reindex
axes, level, limit, tolerance, method, fill_value, copy
File "/home/developer/PycharmProjects/pandas/pandas/core/generic.py", line 4505, in _reindex_axes
allow_dups=False,
File "/home/developer/PycharmProjects/pandas/pandas/core/generic.py", line 4550, in _reindex_with_indexers
copy=copy,
File "/home/developer/PycharmProjects/pandas/pandas/core/internals/managers.py", line 1255, in reindex_indexer
self.axes[axis]._can_reindex(indexer)
File "/home/developer/PycharmProjects/pandas/pandas/core/indexes/base.py", line 3235, in _can_reindex
raise ValueError("cannot reindex from a duplicate axis")
ValueError: cannot reindex from a duplicate axis
Process finished with exit code 1
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#34331 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACI42UP6KNIFB5K35R2QWMLRS6JDPANCNFSM4NIJ4TTQ>.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I try to write an dataframe to excel with excel. It fails if a row is called "render".
Pandas version 1.0.3
Reproduce with:
s1 = pandas.Series(("1","2"),index=["a","b"])
s2 = pandas.Series(("3","4"),index=["b","b"])
df = pandas.DataFrame({"render":s1,"huhu":s2})
df.to_excel("/tmp/out.xlsx")
gives:
AttributeError Traceback (most recent call last)
in
----> 1 df.to_excel("/tmp/out.xlsx")
/usr/local/anaconda3/envs/exoplanets/lib/python3.7/site-packages/pandas/core/generic.py in to_excel(self, excel_writer, sheet_name, na_rep, float_format, columns, header, index, index_label, startrow, startcol, engine, merge_cells, encoding, inf_rep, verbose, freeze_panes)
2171 index_label=index_label,
2172 merge_cells=merge_cells,
-> 2173 inf_rep=inf_rep,
2174 )
2175 formatter.write(
/usr/local/anaconda3/envs/exoplanets/lib/python3.7/site-packages/pandas/io/formats/excel.py in init(self, df, na_rep, float_format, cols, header, index, index_label, merge_cells, inf_rep, style_converter)
384 if hasattr(df, "render"):
385 self.styler = df
--> 386 df = df.data
387 if style_converter is None:
388 style_converter = CSSToExcelConverter()
/usr/local/anaconda3/envs/exoplanets/lib/python3.7/site-packages/pandas/core/generic.py in getattr(self, name)
5272 if self._info_axis._can_hold_identifiers_and_holds_name(name):
5273 return self[name]
-> 5274 return object.getattribute(self, name)
5275
5276 def setattr(self, name: str, value) -> None:
AttributeError: 'DataFrame' object has no attribute 'data'
The text was updated successfully, but these errors were encountered: