split() got an unexpected keyword argument 'expand'

馋奶兔 提交于 2019-12-23 05:29:28

问题


In python2 i could go from this pandas series

        0
0    [a,b,c]

with s.str.split(',',expand=True) into this:

  0 1 2

0 a b c

and now (ipython3) i cant, because lack of "expand" argument. How I can do it in other way?


回答1:


You should check your environment's pandas version. According to the pandas docs, expand was recently added so it looks like you regressed your version somehow.

expand : bool, default False If True, return DataFrame/MultiIndex expanding dimensionality. If False, return Series/Index. New in version 0.16.1.

Based on the old docs it looks like you can do the same thing by specifying the return_type='frame' parameter.



来源:https://stackoverflow.com/questions/35567162/split-got-an-unexpected-keyword-argument-expand

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