Skip to content

pandas date_range as index causes TypeError on repr #716

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

Closed
jonathanstrong opened this issue Jan 12, 2016 · 2 comments
Closed

pandas date_range as index causes TypeError on repr #716

jonathanstrong opened this issue Jan 12, 2016 · 2 comments
Labels

Comments

@jonathanstrong
Copy link

love this library btw, much thanks.

>>> import pandas as pd
>>> import numpy as np
>>> import xray
>>> pd.__version__
u'0.17.1'
>>> np.__version__
'1.10.4'
>>> xray.__version__
'0.6.1'
>>> import pytz
>>> import datetime
>>> datetime_index = pd.date_range(start=datetime.datetime.now(), tz=pytz.timezone('America/New_York'), periods=32, freq='1h')
>>> da = xray.DataArray(data=a, dims=['example', 'channel', 'row', 'column'], coords={'example': datetime_index, 'channel': np.arange(1), 'row': np.arange(28), 'column': np.arange(28)})
>>> print da
Traceback (most recent call last):
[...]
TypeError: data type not understood
@jonathanstrong
Copy link
Author

sorry, forgot to mention, calling to_list() on the datetime_index allows it to work.

>>> da = xray.DataArray(data=a, dims=['example', 'channel', 'row', 'column'], coords={'example': datetime_index.tolist(), 'channel': np.arange(1), 'row': np.arange(28), 'column': np.arange(28)})
>>> print da
<xray.DataArray (example: 32, channel: 1, row: 28, column: 28)>
array([[[[ 0.2415703 ,  0.49185786,  0.76974749, ...,  0.24266482,
           0.51117921,  0.23183344],
         [ 0.5396343 ,  0.7049137 ,  0.46284154, ...,  0.14457754,
           0.5515094 ,  0.06407724],
         [ 0.6545502 ,  0.79442538,  0.61539481, ...,  0.08185602,
           0.07505339,  0.71784597],
         ..., 
         [ 0.74341592,  0.58249646,  0.9264281 , ...,  0.4105471 ,
           0.18713031,  0.38448372],
         [ 0.10294858,  0.08118397,  0.03903754, ...,  0.53996466,
           0.06814973,  0.37088457],
         [ 0.79747167,  0.71836927,  0.3760608 , ...,  0.00207118,
           0.23272135,  0.39850314]]],


       [[[ 0.54520578,  0.82793812,  0.27934314, ...,  0.47675878,
           0.35750073,  0.81324566],
         [ 0.34234289,  0.26131611,  0.1741479 , ...,  0.23433841,
           0.70296677,  0.60834615],
         [ 0.49224854,  0.35010889,  0.72760039, ...,  0.9655428 ,
           0.28976407,  0.94971166],
         ..., 
         [ 0.52062892,  0.62694481,  0.74069292, ...,  0.14967457,
           0.57194567,  0.20518411],
         [ 0.30441499,  0.29161604,  0.49102084, ...,  0.81442707,
           0.18248721,  0.88117849],
         [ 0.91370959,  0.93829229,  0.79401123, ...,  0.26210045,
           0.00614292,  0.75532125]]],


       [[[ 0.08424663,  0.51539268,  0.15021821, ...,  0.6983625 ,
           0.2479839 ,  0.45416423],
         [ 0.41073492,  0.30244808,  0.23658923, ...,  0.64526482,
           0.39558868,  0.77243522],
         [ 0.91946504,  0.14702082,  0.44866339, ...,  0.88202992,
           0.7439115 ,  0.69984251],
         ..., 
         [ 0.33138424,  0.65155252,  0.512169  , ...,  0.12812792,
           0.11201082,  0.52092288],
         [ 0.40670197,  0.04778641,  0.8280053 , ...,  0.96303147,
           0.00902775,  0.27478836],
         [ 0.63061898,  0.65237575,  0.44703296, ...,  0.26827483,
           0.62652144,  0.33875215]]],


       ..., 
       [[[ 0.02181055,  0.28960575,  0.20066007, ...,  0.96958491,
           0.48909334,  0.53350904],
         [ 0.32687157,  0.87064061,  0.75603015, ...,  0.51215617,
           0.22192232,  0.53660243],
         [ 0.53602119,  0.78761882,  0.61880669, ...,  0.40650488,
           0.21773892,  0.43152135],
         ..., 
         [ 0.6085028 ,  0.88383046,  0.72063395, ...,  0.62093148,
           0.28592564,  0.00169664],
         [ 0.47644684,  0.08029548,  0.2617365 , ...,  0.71717209,
           0.82374822,  0.67171277],
         [ 0.91905357,  0.54944082,  0.83455056, ...,  0.50262155,
           0.20663823,  0.0462887 ]]],


       [[[ 0.38780989,  0.28305091,  0.32381702, ...,  0.55012613,
           0.91371051,  0.18266697],
         [ 0.27822897,  0.19429443,  0.56619312, ...,  0.43792798,
           0.28703397,  0.48266462],
         [ 0.31136054,  0.81075836,  0.63331665, ...,  0.71262749,
           0.2267146 ,  0.81515838],
         ..., 
         [ 0.98302595,  0.85393531,  0.43698721, ...,  0.99933458,
           0.80326649,  0.87700763],
         [ 0.91663997,  0.30024646,  0.5544715 , ...,  0.5316829 ,
           0.2144375 ,  0.90622478],
         [ 0.46303225,  0.47611954,  0.17224521, ...,  0.6319952 ,
           0.22626302,  0.23822273]]],


       [[[ 0.20930888,  0.98717439,  0.07440003, ...,  0.93006893,
           0.87313465,  0.55199699],
         [ 0.56638815,  0.6957562 ,  0.14855453, ...,  0.5018839 ,
           0.88542717,  0.7561218 ],
         [ 0.46551802,  0.96133623,  0.94580378, ...,  0.09468893,
           0.30283214,  0.42860321],
         ..., 
         [ 0.14302203,  0.23090552,  0.84507949, ...,  0.89370003,
           0.23141406,  0.94566799],
         [ 0.75805896,  0.9181345 ,  0.63149841, ...,  0.18180786,
           0.94189951,  0.28630845],
         [ 0.02315291,  0.90541336,  0.86396254, ...,  0.36885415,
           0.57690491,  0.60685422]]]])
Coordinates:
  * column   (column) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ...
  * example  (example) datetime64[ns] 2016-01-12T15:31:25.870931 ...
  * channel  (channel) int64 0
  * row      (row) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ...

@shoyer shoyer added the bug label Jan 12, 2016
@shoyer
Copy link
Member

shoyer commented Jan 12, 2016

We can't handle pandas's custom dtype (e.g., datetime64[ns] with a timezone), and right now we fail very loudly when that happens.

We've encountered a few examples of this recently -- I'll see if I can clean this up for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants