代码:
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 ,则忽略该行
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)当一个人真正发生的事情意味着什么?