我是来自奥古拉普利斯的<>大范围>包裹的新用户。 我正试图操纵装自Bigquery的数据。
我正试图执行某些法典,但我正面临一个无法解决的问题。
I am trying to use the apply function on a Dataframe with the parameter axis=1 , but it doesn t seem to work. I always have an error message.
你们能否帮助我这样做?
感谢。
法典例
# example
def condition(row):
print(row )
if 1 <= row["month"] <= 6:
return f"{row[ year ]:02}S1{row[ CODPY ]}{row[ CODDE ]}"
else:
return f"{row[ year ]:02}S2{row[ CODPY ]}{row[ CODDE ]}"
valodetail_df[ IDT ] = valodetail_df.apply(condition,axis=1)
跟踪
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ubuntu/miniconda3/envs/qback/lib/python3.11/site-packages/bigframes/core/log_adapter.py", line 44, in wrapper
return method(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/miniconda3/envs/qback/lib/python3.11/site-packages/bigframes/dataframe.py", line 3118, in apply
results = {name: func(col, *args, **kwargs) for name, col in self.items()}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/miniconda3/envs/qback/lib/python3.11/site-packages/bigframes/dataframe.py", line 3118, in <dictcomp>
results = {name: func(col, *args, **kwargs) for name, col in self.items()}
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<stdin>", line 3, in condition
File "missing.pyx", line 419, in pandas._libs.missing.NAType.__bool__
TypeError: boolean value of NA is ambiguous
>>> valodetail_df[ IDTDCI ] = valodetail_df.apply(condition,axis=1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ubuntu/miniconda3/envs/qback/lib/python3.11/site-packages/bigframes/core/log_adapter.py", line 44, in wrapper
return method(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/miniconda3/envs/qback/lib/python3.11/site-packages/bigframes/dataframe.py", line 3118, in apply
results = {name: func(col, *args, **kwargs) for name, col in self.items()}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/miniconda3/envs/qback/lib/python3.11/site-packages/bigframes/dataframe.py", line 3118, in <dictcomp>
results = {name: func(col, *args, **kwargs) for name, col in self.items()}
^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: condition() got an unexpected keyword argument axis