-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Transpose fails on DataFrame with timestamps having timezone #17539
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
Labels
Datetime
Datetime data dtype
Duplicate Report
Duplicate issue or pull request
Reshaping
Concat, Merge/Join, Stack/Unstack, Explode
Timezones
Timezone data dtype
Comments
Another case, where error indicates In [64]: pd.DataFrame(pd.date_range(pd.to_datetime('now'), periods=2, freq='D'))
Out[64]:
0
0 2017-09-15 10:49:12
1 2017-09-16 10:49:12
In [65]: pd.DataFrame(pd.date_range(pd.to_datetime('now'), periods=2, freq='D', tz='UTC'))
Out[65]:
0
0 2017-09-15 10:49:14+00:00
1 2017-09-16 10:49:14+00:00
In [66]: pd.DataFrame(pd.date_range(pd.to_datetime('now'), periods=2, freq='D')).T
Out[66]:
0 1
0 2017-09-15 10:49:16 2017-09-16 10:49:16
In [67]: pd.DataFrame(pd.date_range(pd.to_datetime('now'), periods=2, freq='D', tz='UTC')).T
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-67-3ba6caaa2c38> in <module>()
----> 1 pd.DataFrame(pd.date_range(pd.to_datetime('now'), periods=2, freq='D', tz='UTC')).T
e:\github\pandas\pandas\core\frame.pyc in transpose(self, *args, **kwargs)
1876 """Transpose index and columns"""
1877 nv.validate_transpose(args, dict())
-> 1878 return super(DataFrame, self).transpose(1, 0, **kwargs)
1879
1880 T = property(transpose)
e:\github\pandas\pandas\core\generic.pyc in transpose(self, *args, **kwargs)
595 new_axes = self._construct_axes_dict_from(self, [self._get_axis(x)
596 for x in axes_names])
--> 597 new_values = self.values.transpose(axes_numbers)
598 if kwargs.pop('copy', None) or (len(args) and args[-1]):
599 new_values = new_values.copy()
e:\github\pandas\pandas\core\base.pyc in transpose(self, *args, **kwargs)
782 def transpose(self, *args, **kwargs):
783 """ return the transpose, which is by definition self """
--> 784 nv.validate_transpose(args, kwargs)
785 return self
786
e:\github\pandas\pandas\compat\numpy\function.pyc in __call__(self, args, kwargs, fname, max_fname_arg_count, method)
52 validate_args_and_kwargs(fname, args, kwargs,
53 max_fname_arg_count,
---> 54 self.defaults)
55 else:
56 raise ValueError("invalid validation method "
e:\github\pandas\pandas\util\_validators.pyc in validate_args_and_kwargs(fname, args, kwargs, max_fname_arg_count, compat_args)
215
216 kwargs.update(args_dict)
--> 217 validate_kwargs(fname, kwargs, compat_args)
218
219
e:\github\pandas\pandas\util\_validators.pyc in validate_kwargs(fname, kwargs, compat_args)
154 kwds = kwargs.copy()
155 _check_for_invalid_keys(fname, kwargs, compat_args)
--> 156 _check_for_default_values(fname, kwds, compat_args)
157
158
e:\github\pandas\pandas\util\_validators.pyc in _check_for_default_values(fname, arg_val_dict, compat_args)
66 "supported in the pandas "
67 "implementation of {fname}()".
---> 68 format(fname=fname, arg=key)))
69
70
ValueError: the 'axes' parameter is not supported in the pandas implementation of transpose() |
this is a manifestation and duplicate of #13287 |
pull requests to fix are welcome |
Ah, thanks, apologies didn't search enough. Is that issue also causing In [108]: pd.DataFrame(pd.date_range('2014', periods=2, freq='D')).max(axis=1)
Out[108]:
0 2014-01-01
1 2014-01-02
dtype: datetime64[ns]
In [109]: pd.DataFrame(pd.date_range('2014', periods=2, freq='D', tz='UTC')).max(axis=1)
Out[109]:
0 NaN
1 NaN
dtype: float64 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Datetime
Datetime data dtype
Duplicate Report
Duplicate issue or pull request
Reshaping
Concat, Merge/Join, Stack/Unstack, Explode
Timezones
Timezone data dtype
Code
Problem description
Transpose on dataframe with timestamps columns work. But, if columns consist of timestamps with time-zone, it fails.
Output of
pd.show_versions()
pandas: 0.21.0.dev+413.g7f93d2d
pytest: 3.2.0
pip: 9.0.1
setuptools: 36.2.7
Cython: 0.24.1
numpy: 1.12.1
scipy: 0.19.1
pyarrow: None
xarray: None
IPython: 5.1.0
sphinx: 1.4.6
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2017.2
blosc: None
bottleneck: 1.2.0
tables: 3.2.2
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.3.2
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: 0.9.3
lxml: 3.6.4
bs4: 4.5.1
html5lib: 0.999999999
sqlalchemy: 1.0.13
pymysql: 0.7.9.None
psycopg2: 2.7.3.1 (dt dec pq3 ext lo64)
jinja2: 2.8
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: