小编sto*_*rms的帖子

如何输入提示 pandas.NA 作为可能的输出

我有 Pandas lambda 函数,我将其与.apply.

此函数将输出一个字典,其中包含字符串键和值为字符串或pd.NA.

当我尝试输入提示函数时,出现错误:

def _the_function(x: str) -> dict[str, str | pd.NA]:
    ...
Run Code Online (Sandbox Code Playgroud)
ERROR: Expected class type but received "NAType"
Run Code Online (Sandbox Code Playgroud)

如何pd.NA在不必导入 numpy 并使用其NaN类型提示的情况下告诉它可能的值?我的项目不需要导入numpy。

python nan type-hinting pandas python-typing

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

标签 统计

nan ×1

pandas ×1

python ×1

python-typing ×1

type-hinting ×1