想根据计数、A 和 B 的值计算 C
示例 df:
| 数数 | 一种 | 乙 | C |
|---|---|---|---|
| 是的 | 23 | 2 | 南 |
| 南 | 23 | 1 | 南 |
| 是的 | 41 | 6 | 南 |
我想要的结果
| 数数 | 一种 | 乙 | C |
|---|---|---|---|
| 是的 | 23 | 2 | 46 |
| 南 | 23 | 1 | 0 |
| 是的 | 41 | 6 | 246 |
仅当计数值 = yes 时才计算 C = A*B 否则 C 值 =0 即应跳过计数的 nan 值
任何帮助都是可观的
我正在尝试这个
for ind, row in df.iterrows():
if df['count'] == 'yes':
df.loc[ ind, 'C'] =row['A'] *row['B']
else:
df.loc[ ind, 'C'] =0
Run Code Online (Sandbox Code Playgroud)
但它给出了错误: ValueError: 系列的真值不明确。使用 a.empty、a.bool()、a.item()、a.any() 或 …
我有一张雪花表,我正在使用它执行批量加载。表中的列之一是日期,但在 sql server 上的源表中,日期列中有空值。
数据流如下:
sql_server-->S3存储桶-->snowflake_table
我能够在 EMR 中执行 sqoop 作业,但无法将数据加载到雪花表中,因为它不接受日期列中的空值。
错误是:
Date '' is not recognized File 'schema_name/table_name/file1', line 2, character 18 Row 2,
column "table_name"["column_name":5] If you would like to continue loading when an error is
encountered, use other values such as 'SKIP_FILE' or 'CONTINUE' for the ON_ERROR option.
Run Code Online (Sandbox Code Playgroud)
谁能帮忙,我失踪的地方
amazon-web-services amazon-emr snowflake-cloud-data-platform
下面是一个简单的类,其中有一个方法/函数
class Test():
def f(self):
return "function or method"
Run Code Online (Sandbox Code Playgroud)
我应该在这里调用什么f()- 方法还是函数?