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
This is an obscure edge case, but I feel it needs to be reported.
For an empty dataframe with 2 or more columns, setting with enlargment of a row that includes a timezoned timestamp, fails.
from pandas import DataFrame, Timestamp
# works:
df = DataFrame(columns=['a', 'b'])
df.loc[len(df)] = [Timestamp.now(), 55]
# does not work:
df = DataFrame(columns=['a', 'b'])
df.loc[len(df)] = [Timestamp.now(tz='Europe/Paris'), 55]
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/IPython/core/interactiveshell.py", line 3066, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-53-b144415de186>", line 1, in <module>
df.loc[len(df)] = [Timestamp.now(tz='Europe/Paris'), 55]
File "/usr/local/lib/python3.4/dist-packages/pandas/core/indexing.py", line 141, in __setitem__
self._setitem_with_indexer(indexer, value)
File "/usr/local/lib/python3.4/dist-packages/pandas/core/indexing.py", line 385, in _setitem_with_indexer
self.obj._data = self.obj.append(value)._data
File "/usr/local/lib/python3.4/dist-packages/pandas/core/frame.py", line 4435, in append
verify_integrity=verify_integrity)
File "/usr/local/lib/python3.4/dist-packages/pandas/tools/merge.py", line 1452, in concat
return op.get_result()
File "/usr/local/lib/python3.4/dist-packages/pandas/tools/merge.py", line 1650, in get_result
copy=self.copy)
File "/usr/local/lib/python3.4/dist-packages/pandas/core/internals.py", line 4825, in concatenate_block_managers
placement=placement) for placement, join_units in concat_plan]
File "/usr/local/lib/python3.4/dist-packages/pandas/core/internals.py", line 4825, in <listcomp>
placement=placement) for placement, join_units in concat_plan]
File "/usr/local/lib/python3.4/dist-packages/pandas/core/internals.py", line 4922, in concatenate_join_units
for ju in join_units]
File "/usr/local/lib/python3.4/dist-packages/pandas/core/internals.py", line 4922, in <listcomp>
for ju in join_units]
File "/usr/local/lib/python3.4/dist-packages/pandas/core/internals.py", line 5195, in get_reindexed_values
missing_arr = np.empty(self.shape, dtype=empty_dtype)
TypeError: data type not understood
If you are encountering this issue and need a quick workaround (as I did), try temporarily setting a timestamp to the table missing timstamps. Then set the values to np.nan or None after concating.
This is an obscure edge case, but I feel it needs to be reported.
For an empty dataframe with 2 or more columns, setting with enlargment of a row that includes a timezoned timestamp, fails.
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: