我是 Polars 新用户。熊猫有df.dropna。我需要替换此功能,但我还没有在极地找到 dropna。drona在 Polars 用户指南中搜索当前没有结果。
我的具体问题:将以下语句从 pandas 转换为 Polars
\ndf.dropna(subset=list_of_vars, thresh=1)
我想我应该使用df.filter. 我不知道先验的内容list_of_vars,因此制作一组|过滤器有点棘手。所有变量list_of_vars都是数据框中的列
输入
\nimport polars as pl\n\ndf = pl.DataFrame(\n {\n \'col1\':[0,float(\'nan\'),2,3],\n \'col2\':[0,float(\'nan\'),float(\'nan\'),3],\n \'col3\':[0,1,2,3],\n \'col3\':[float(\'nan\'),float(\'nan\'),float(\'nan\'),float(\'nan\')]\n }\n)\ndf\nlist_of_vars = [\'col1\', \'col2\']\nRun Code Online (Sandbox Code Playgroud)\n期望的输出:
\n仅保留数据框中至少一列的值list_of_vars不为 NaN/null 的行。
\xe2\x94\x8c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xac\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x90\n\xe2\x94\x82 col1 \xe2\x94\x86 col2 \xe2\x94\x86 col3 \xe2\x94\x86 col4 \xe2\x94\x82\n\xe2\x94\x82 --- \xe2\x94\x86 --- \xe2\x94\x86 --- \xe2\x94\x86 --- \xe2\x94\x82\n\xe2\x94\x82 f64 \xe2\x94\x86 f64 \xe2\x94\x86 i64 \xe2\x94\x86 f64 …Run Code Online (Sandbox Code Playgroud)