Skip to content

TypeError casting int64 to int32 when shifting time series #8129

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
goyodiaz opened this issue Aug 28, 2014 · 3 comments
Closed

TypeError casting int64 to int32 when shifting time series #8129

goyodiaz opened this issue Aug 28, 2014 · 3 comments
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions
Milestone

Comments

@goyodiaz
Copy link
Contributor

I think I hit another 32bits issue. This happens in Win7 32 bits:

Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> index = pd.date_range('2000-01-01', periods=5, freq='D')
>>> s1 = pd.Series(range(5), index=index)
>>> p = s1.iloc[1]
>>> s1.shift(periods=p)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Python27\lib\site-packages\pandas\core\generic.py", line 3290, in shift
    new_data = self._data.shift(periods=periods, axis=block_axis)
  File "D:\Python27\lib\site-packages\pandas\core\internals.py", line 2228, in shift
    return self.apply('shift', **kwargs)
  File "D:\Python27\lib\site-packages\pandas\core\internals.py", line 2192, in apply
    applied = getattr(b, f)(**kwargs)
  File "D:\Python27\lib\site-packages\pandas\core\internals.py", line 791, in shift
    new_values = np.roll(new_values, periods, axis=axis)
  File "D:\Python27\lib\site-packages\numpy\core\numeric.py", line 1294, in roll
    res = a.take(indexes, axis)
TypeError: Cannot cast array data from dtype('int64') to dtype('int32') according to the rule 'safe'
>>> pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.6.final.0
python-bits: 32
OS: Windows
OS-release: 7
machine: x86
processor: x86 Family 6 Model 58 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.14.1
nose: 1.3.3
Cython: None
numpy: 1.8.1
scipy: 0.14.0
statsmodels: 0.5.0
IPython: 2.2.0
sphinx: 1.2.2
patsy: 0.2.1
scikits.timeseries: None
dateutil: 2.2
pytz: 2014.3
bottleneck: 0.8.0
tables: 3.1.1
numexpr: 2.4
matplotlib: 1.4.0
openpyxl: None
xlrd: 0.9.3
xlwt: 0.7.5
xlsxwriter: None
lxml: 3.3.5
bs4: 4.3.2
html5lib: 0.999
httplib2: None
apiclient: None
rpy2: None
sqlalchemy: 0.9.4
pymysql: None
psycopg2: None
@jreback
Copy link
Contributor

jreback commented Aug 28, 2014

yep

its an easy fix if you want to do a PR

use com._ensure_platform_int when passing periods to np.roll

@jreback jreback added this to the 0.15.0 milestone Aug 28, 2014
@jreback
Copy link
Contributor

jreback commented Sep 17, 2014

hmm, I can no longer reproduce this (IIRC I did fix something about this)....can you try with a recent windows release and update? https://github.com/pydata/pandas/releases

@jreback
Copy link
Contributor

jreback commented Sep 17, 2014

closed by 83ff5b1

(this is not on the release pages yet)

@jreback jreback closed this as completed Sep 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

No branches or pull requests

2 participants