相关疑难解决方法(0)

pandas如何检查列是否不为空然后在一行代码中应用.str.replace

代码:

df['Rep'] = df['Rep'].str.replace('\\n', ' ')
Run Code Online (Sandbox Code Playgroud)

问题:如果 df['Rep'] 为空或 null ,则会出现错误:

Failed: Can only use .str accessor with string values!
Run Code Online (Sandbox Code Playgroud)

无论如何可以处理列值为空或为空时的情况吗?如果为空或 null ,则忽略该行

python dataframe pandas

5
推荐指数
1
解决办法
340
查看次数

FutureWarning:关于 `df['col'].apply(p.Series)`

 FutureWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.
Run Code Online (Sandbox Code Playgroud)

在做的时候

rc = dataset_ex[column_name].apply(p.Series)

如何避免警告?df.apply(pd.Series)当一个人真正发生的事情意味着什么?

pandas

3
推荐指数
1
解决办法
1552
查看次数

标签 统计

pandas ×2

dataframe ×1

python ×1