aliyun / aliyun-odps-python-sdk

ODPS Python SDK and data analysis framework
http://pyodps.readthedocs.io
Apache License 2.0
434 stars 97 forks source link

AttributeError: module 'pandas' has no attribute 'expanding_median' #71

Closed iris-qq closed 6 years ago

iris-qq commented 6 years ago

我在使用odps的时候,在读取数据想转化为pandas中的DataFrame类型,但是报错了,不知道是什么情况,按照教材来写的代码。` class Conntect_odps(object):

def __init__(self,access_id,access_key,default_project,end_point=None):
    self.access_id = access_id
    self.access_key = access_key
    self.default_project = default_project
    self.end_point = end_point

def get_connection(self):
    odps = ODPS(self.access_id,self.access_key,self.default_project,self.end_point)
    return odps

def put_data(self):
    odps = self.get_connection()
    project = odps.get_project(self.default_project)
    table = DataFrame(odps.get_table('dw_projects_disease_mark',project=project))
    print(type(table.to_pandas()))

Traceback (most recent call last): File "C:/Users/qiqia/Desktop/pt_sdk.py", line 43, in Co.put_data() File "C:/Users/qiqia/Desktop/pt_sdk.py", line 25, in put_data print(type(table.to_pandas())) File "C:\Users\qiqia\AppData\Local\Programs\Python\Python36-32\lib\site-packages\odps\df\expr\expressions.py", line 43, in call return self._func(args, kwargs) File "C:\Users\qiqia\AppData\Local\Programs\Python\Python36-32\lib\site-packages\odps\df\expr\expressions.py", line 1091, in to_pandas return self.execute(wrapper=wrapper, kwargs) File "C:\Users\qiqia\AppData\Local\Programs\Python\Python36-32\lib\site-packages\odps\df\expr\expressions.py", line 43, in call return self._func(args, kwargs) File "C:\Users\qiqia\AppData\Local\Programs\Python\Python36-32\lib\site-packages\odps\df\expr\expressions.py", line 191, in execute return self._handle_delay_call('execute', self, wrapper=wrapper, kwargs) File "C:\Users\qiqia\AppData\Local\Programs\Python\Python36-32\lib\site-packages\odps\df\expr\expressions.py", line 43, in call return self._func(*args, **kwargs) File "C:\Users\qiqia\AppData\Local\Programs\Python\Python36-32\lib\site-packages\odps\df\expr\expressions.py", line 142, in _handle_delay_call from ..engines import get_default_engine File "C:\Users\qiqia\AppData\Local\Programs\Python\Python36-32\lib\site-packages\odps\df\engines.py", line 17, in from .backends.engine import get_default_engine File "C:\Users\qiqia\AppData\Local\Programs\Python\Python36-32\lib\site-packages\odps\df\backends\engine.py", line 26, in from .pd.engine import PandasEngine File "C:\Users\qiqia\AppData\Local\Programs\Python\Python36-32\lib\site-packages\odps\df\backends\pd\engine.py", line 20, in from .compiler import PandasCompiler File "C:\Users\qiqia\AppData\Local\Programs\Python\Python36-32\lib\site-packages\odps\df\backends\pd\compiler.py", line 81, in 'CumMedian': pd.expanding_median, AttributeError: module 'pandas' has no attribute 'expanding_median'

Process finished with exit code 1 `

iris-qq commented 6 years ago

发现问题是因为pandas的版本升级之后,expanding_系列的属性都取消了,所以在执行的时候源码中的compiler.py中使用了这一系列的属性,导致报错。需要把pandas降级到0.17.

qinxuye commented 6 years ago

0.22 就可以了,这个已经修复了,近期会同步到 Github