Concat of dataframe with tz-aware datetime column against dataframe without, fails · Issue #22796 · pandas-dev/pandas (original) (raw)
a = pd.DataFrame([[1, 2]], dtype='datetime64[ns, UTC]') b = pd.DataFrame([[3]], dtype='datetime64[ns, UTC]') pd.concat([a, b])
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-42-457226d62f27> in <module>()
1 a = pd.DataFrame([[1, 2]], dtype='datetime64[ns, UTC]')
2 b = pd.DataFrame([[3]], dtype='datetime64[ns, UTC]')
----> 3 pd.concat([a, b])
~/.pyenv/versions/3.6.2/envs/general/lib/python3.6/site-packages/pandas/core/reshape/concat.py in concat(objs, axis, join, join_axes, ignore_index, keys, levels, names, verify_integrity, sort, copy)
224 verify_integrity=verify_integrity,
225 copy=copy, sort=sort)
--> 226 return op.get_result()
227
228
~/.pyenv/versions/3.6.2/envs/general/lib/python3.6/site-packages/pandas/core/reshape/concat.py in get_result(self)
421 new_data = concatenate_block_managers(
422 mgrs_indexers, self.new_axes, concat_axis=self.axis,
--> 423 copy=self.copy)
424 if not self.copy:
425 new_data._consolidate_inplace()
~/.pyenv/versions/3.6.2/envs/general/lib/python3.6/site-packages/pandas/core/internals.py in concatenate_block_managers(mgrs_indexers, axes, concat_axis, copy)
5419 else:
5420 b = make_block(
-> 5421 concatenate_join_units(join_units, concat_axis, copy=copy),
5422 placement=placement)
5423 blocks.append(b)
~/.pyenv/versions/3.6.2/envs/general/lib/python3.6/site-packages/pandas/core/internals.py in concatenate_join_units(join_units, concat_axis, copy)
5563 to_concat = [ju.get_reindexed_values(empty_dtype=empty_dtype,
5564 upcasted_na=upcasted_na)
-> 5565 for ju in join_units]
5566
5567 if len(to_concat) == 1:
~/.pyenv/versions/3.6.2/envs/general/lib/python3.6/site-packages/pandas/core/internals.py in <listcomp>(.0)
5563 to_concat = [ju.get_reindexed_values(empty_dtype=empty_dtype,
5564 upcasted_na=upcasted_na)
-> 5565 for ju in join_units]
5566
5567 if len(to_concat) == 1:
~/.pyenv/versions/3.6.2/envs/general/lib/python3.6/site-packages/pandas/core/internals.py in get_reindexed_values(self, empty_dtype, upcasted_na)
5849
5850 if not self.indexers:
-> 5851 if not self.block._can_consolidate:
5852 # preserve these for validation in _concat_compat
5853 return self.block.values
AttributeError: 'NoneType' object has no attribute '_can_consolidate'