Pandas 0.21.1 - DataFrame.replace recursion error

依然范特西╮ 提交于 2020-01-04 05:28:12

问题


I was used to run this code with no issue:

data_0 = data_0.replace([-1, 'NULL'], [None, None])

now, after the update to Pandas 0.21.1, with the very same line of code I get a:

recursionerror: maximum recursion depth exceeded

does anybody experience the same issue ? and knows how to solve ?

Note: rolling back to pandas 0.20.3 will make the trick but I think it's important to solve with latest version

thanx


回答1:


I think this error message depends on what your input data is. Here's an example of input data where this works in the expected way:

data_0 = pd.DataFrame({'x': [-1, 1], 'y': ['NULL', 'foo']})
data_0.replace([-1, 'NULL'], [None, None])

replaces values of -1 and 'NULL' with None:

    x     y
0  NaN  None
1  1.0   foo


来源:https://stackoverflow.com/questions/47791164/pandas-0-21-1-dataframe-replace-recursion-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!