Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何从列中删除空列表?_Python 3.x_String_Pandas - Fatal编程技术网

Python 3.x 如何从列中删除空列表?

Python 3.x 如何从列中删除空列表?,python-3.x,string,pandas,Python 3.x,String,Pandas,我有一个像这样的df list [] [8,8] [0,9] [] 此列的数据类型为对象。如何从列中删除[],并替换为np.nan 我尝试过字符串替换,但括号不可用 df.list = df.list.replace('"[]"','') 使用astype(bool) 太好了,谢谢! df=df[df['list'].astype(bool)]

我有一个像这样的df

list
[]
[8,8]
[0,9]
[]
此列的数据类型为
对象
。如何从列中删除
[]
,并替换为np.nan

我尝试过字符串替换,但括号不可用

df.list = df.list.replace('"[]"','')
使用
astype(bool)


太好了,谢谢!
df=df[df['list'].astype(bool)]