Bryan Cutler created ARROW-1906:
-----------------------------------

             Summary: [Python] Creating a pyarrow.Array with timestamp of 
different unit is not casted
                 Key: ARROW-1906
                 URL: https://issues.apache.org/jira/browse/ARROW-1906
             Project: Apache Arrow
          Issue Type: Bug
          Components: Python
            Reporter: Bryan Cutler


This is similar to ARROW-1680 but slightly different in that an error is not 
raised but the unit will still remain unchanged only when using a timezone

{noformat}
In [47]: us_with_tz = pa.timestamp('us', tz='America/New_York')

In [48]: s = pd.Series([val])

In [49]: s_nyc = s.dt.tz_localize('tzlocal()').dt.tz_convert('America/New_York')

In [50]: arr = pa.Array.from_pandas(s_nyc, type=us_with_tz)

In [51]: arr.type
Out[51]: TimestampType(timestamp[ns, tz=America/New_York])

In [52]: arr2 = pa.Array.from_pandas(s, type=pa.timestamp('us'))

In [53]: arr2.type
Out[53]: TimestampType(timestamp[us])
{noformat}

There is an easy workaround to apply the cast after creating the pyarrow.Array, 
which seems to work fine

{noformat}
In [54]: arr = pa.Array.from_pandas(s_nyc).cast(us_with_tz, safe=False)

In [55]: arr.type
Out[55]: TimestampType(timestamp[us, tz=America/New_York])
{noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to