2012-05-20 10 views
0

팬더의 간단한 시계열에서 부동 소수점 오류가 발생합니다. 나는 교대 조작을하려고 노력하고있다 ... 그러나 이것은 또한 창 기능과 함께 발생한다. rolling_mean.팬더 부동 소수점 오류

편집 : 몇 가지 추가 정보 ... 실제로 오류가 발생하기 전에 어제 원본을 빌드하려고했습니다. 오류가 빌드 시도 이전에 발생했는지 확실하지 않습니다. 이러한 함수를 사용하지 않았을 것입니다.

EDIT2 : 저는 이것을 고쳐야한다고 생각했지만, 이것을 파이썬 내부에서 실행하면 ipython에 오류가 발생합니다.

EDIT3 : NumPy와 1.7.0, iPython 0.13, 팬더 0.7.3

In [35]: ts = Series(np.arange(12), index=DateRange('1/1/2000', periods=12, freq='T')) 

In [36]: ts.shift(0) 
Out[36]: 
2000-01-03  0 
2000-01-04  1 
2000-01-05  2 
2000-01-06  3 
2000-01-07  4 
2000-01-10  5 
2000-01-11  6 
2000-01-12  7 
2000-01-13  8 
2000-01-14  9 
2000-01-17 10 
2000-01-18 11 

In [37]: ts.shift(1) 
Out[37]: --------------------------------------------------------------------------- 
FloatingPointError      Traceback (most recent call last) 
/Users/trenthauck/Repository/work/SQS/analysis/campaign/tv2/data/<ipython-input-37-2b7cec97d440> in <module>() 
----> 1 ts.shift(1) 

/Library/Python/2.7/site-packages/ipython-0.13.dev-py2.7.egg/IPython/core/displayhook.pyc in __call__(self, result) 
    236    self.start_displayhook() 
    237    self.write_output_prompt() 
--> 238    format_dict = self.compute_format_data(result) 
    239    self.write_format_data(format_dict) 
    240    self.update_user_ns(result) 

/Library/Python/2.7/site-packages/ipython-0.13.dev-py2.7.egg/IPython/core/displayhook.pyc in compute_format_data(self, result) 
    148    MIME type representation of the object. 
    149   """ 
--> 150   return self.shell.display_formatter.format(result) 
    151 
    152  def write_format_data(self, format_dict): 

/Library/Python/2.7/site-packages/ipython-0.13.dev-py2.7.egg/IPython/core/formatters.pyc in format(self, obj, include, exclude) 
    124      continue 
    125    try: 
--> 126     data = formatter(obj) 
    127    except: 
    128     # FIXME: log the exception 

/Library/Python/2.7/site-packages/ipython-0.13.dev-py2.7.egg/IPython/core/formatters.pyc in __call__(self, obj) 
    445     type_pprinters=self.type_printers, 
    446     deferred_pprinters=self.deferred_printers) 
--> 447    printer.pretty(obj) 
    448    printer.flush() 
    449    return stream.getvalue() 

/Library/Python/2.7/site-packages/ipython-0.13.dev-py2.7.egg/IPython/lib/pretty.pyc in pretty(self, obj) 
    353     if callable(obj_class._repr_pretty_): 
    354      return obj_class._repr_pretty_(obj, self, cycle) 
--> 355    return _default_pprint(obj, self, cycle) 
    356   finally: 
    357    self.end_group() 

/Library/Python/2.7/site-packages/ipython-0.13.dev-py2.7.egg/IPython/lib/pretty.pyc in _default_pprint(obj, p, cycle) 
    473  if getattr(klass, '__repr__', None) not in _baseclass_reprs: 
    474   # A user-provided repr. 
--> 475   p.text(repr(obj)) 
    476   return 
    477  p.begin_group(1, '<') 

/Library/Python/2.7/site-packages/pandas/core/series.pyc in __repr__(self) 
    696    result = self._get_repr(print_header=True, 
    697          length=len(self) > 50, 
--> 698          name=True) 
    699   else: 
    700    result = '%s' % ndarray.__repr__(self) 

/Library/Python/2.7/site-packages/pandas/core/series.pyc in _get_repr(self, name, print_header, length, na_rep, float_format) 
    756           length=length, na_rep=na_rep, 
    757           float_format=float_format) 
--> 758   return formatter.to_string() 
    759 
    760  def __str__(self): 

/Library/Python/2.7/site-packages/pandas/core/format.pyc in to_string(self) 
    99 
    100   fmt_index, have_header = self._get_formatted_index() 
--> 101   fmt_values = self._get_formatted_values() 
    102 
    103   maxlen = max(len(x) for x in fmt_index) 

/Library/Python/2.7/site-packages/pandas/core/format.pyc in _get_formatted_values(self) 
    90   return format_array(self.series.values, None, 
    91        float_format=self.float_format, 
---> 92        na_rep=self.na_rep) 
    93 
    94  def to_string(self): 

/Library/Python/2.7/site-packages/pandas/core/format.pyc in format_array(values, formatter, float_format, na_rep, digits, space, justify) 
    431       justify=justify) 
    432 
--> 433  return fmt_obj.get_result() 
    434 
    435 

/Library/Python/2.7/site-packages/pandas/core/format.pyc in get_result(self) 
    528 
    529    # this is pretty arbitrary for now 
--> 530    has_large_values = (np.abs(self.values) > 1e8).any() 
    531 
    532    if too_long and has_large_values: 

FloatingPointError: invalid value encountered in absolute 

In [38]: ts.shift(-1) 
Out[38]: --------------------------------------------------------------------------- 
FloatingPointError      Traceback (most recent call last) 
/Users/myusername/Repository/work/SQS/analysis/campaign/tv2/data/<ipython-input-38-314ec815a7c5> in <module>() 
----> 1 ts.shift(-1) 

/Library/Python/2.7/site-packages/ipython-0.13.dev-py2.7.egg/IPython/core/displayhook.pyc in __call__(self, result) 
    236    self.start_displayhook() 
    237    self.write_output_prompt() 
--> 238    format_dict = self.compute_format_data(result) 
    239    self.write_format_data(format_dict) 
    240    self.update_user_ns(result) 

/Library/Python/2.7/site-packages/ipython-0.13.dev-py2.7.egg/IPython/core/displayhook.pyc in compute_format_data(self, result) 
    148    MIME type representation of the object. 
    149   """ 
--> 150   return self.shell.display_formatter.format(result) 
    151 
    152  def write_format_data(self, format_dict): 

/Library/Python/2.7/site-packages/ipython-0.13.dev-py2.7.egg/IPython/core/formatters.pyc in format(self, obj, include, exclude) 
    124      continue 
    125    try: 
--> 126     data = formatter(obj) 
    127    except: 
    128     # FIXME: log the exception 

/Library/Python/2.7/site-packages/ipython-0.13.dev-py2.7.egg/IPython/core/formatters.pyc in __call__(self, obj) 
    445     type_pprinters=self.type_printers, 
    446     deferred_pprinters=self.deferred_printers) 
--> 447    printer.pretty(obj) 
    448    printer.flush() 
    449    return stream.getvalue() 

/Library/Python/2.7/site-packages/ipython-0.13.dev-py2.7.egg/IPython/lib/pretty.pyc in pretty(self, obj) 
    353     if callable(obj_class._repr_pretty_): 
    354      return obj_class._repr_pretty_(obj, self, cycle) 
--> 355    return _default_pprint(obj, self, cycle) 
    356   finally: 
    357    self.end_group() 

/Library/Python/2.7/site-packages/ipython-0.13.dev-py2.7.egg/IPython/lib/pretty.pyc in _default_pprint(obj, p, cycle) 
    473  if getattr(klass, '__repr__', None) not in _baseclass_reprs: 
    474   # A user-provided repr. 
--> 475   p.text(repr(obj)) 
    476   return 
    477  p.begin_group(1, '<') 

/Library/Python/2.7/site-packages/pandas/core/series.pyc in __repr__(self) 
    696    result = self._get_repr(print_header=True, 
    697          length=len(self) > 50, 
--> 698          name=True) 
    699   else: 
    700    result = '%s' % ndarray.__repr__(self) 

/Library/Python/2.7/site-packages/pandas/core/series.pyc in _get_repr(self, name, print_header, length, na_rep, float_format) 
    756           length=length, na_rep=na_rep, 
    757           float_format=float_format) 
--> 758   return formatter.to_string() 
    759 
    760  def __str__(self): 

/Library/Python/2.7/site-packages/pandas/core/format.pyc in to_string(self) 
    99 
    100   fmt_index, have_header = self._get_formatted_index() 
--> 101   fmt_values = self._get_formatted_values() 
    102 
    103   maxlen = max(len(x) for x in fmt_index) 

/Library/Python/2.7/site-packages/pandas/core/format.pyc in _get_formatted_values(self) 
    90   return format_array(self.series.values, None, 
    91        float_format=self.float_format, 
---> 92        na_rep=self.na_rep) 
    93 
    94  def to_string(self): 

/Library/Python/2.7/site-packages/pandas/core/format.pyc in format_array(values, formatter, float_format, na_rep, digits, space, justify) 
    431       justify=justify) 
    432 
--> 433  return fmt_obj.get_result() 
    434 
    435 

/Library/Python/2.7/site-packages/pandas/core/format.pyc in get_result(self) 
    528 
    529    # this is pretty arbitrary for now 
--> 530    has_large_values = (np.abs(self.values) > 1e8).any() 
    531 
    532    if too_long and has_large_values: 

FloatingPointError: invalid value encountered in absolute 
+0

나를 위해 잘 작동합니다. Python 2.7.3, pandas 0.7.0 – Avaris

+0

감사합니다 - ipython 또는 python에서 이것을 시도한 적이 있습니까? – tshauck

+0

NumPy의 어떤 버전입니까? –

답변

1

내가 주석으로이를 추가,하지만 난 그 아직 :)

을 할 수있는 권한이 없습니다

그것은 파이썬과 iPython 0.12에서 작동합니다; iPython 0.13은 여전히 ​​개발 중이며 (http://ipython.org/ 참조), iPython 0.13 계란에 오류가 발생하고있는 것 같아 그 원인이 될 수 있습니다. 대신 iPython 0.12를 사용해보십시오. 작동한다면 iPython으로 버그 보고서를 제출 한 다음 0.13이 더 안정 될 때까지 0.12로 고정하십시오.

+0

답장을 보내 주셔서 감사 드리며, 여전히 0.12의 오류가 표시됩니다. 그래서 그것은 내 시스템에 보급되어있는 것 같습니다. 이상하게 bpython에서 작동합니다. – tshauck

+0

흠. 그냥 찌르지 만 iPython에서 np.abs ([np.nan, 1, 2, 3])를 시도하면 어떻게됩니까? – Karmel

+0

좋은 캐치 ... 같은 오류가 발생합니다. – tshauck