首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >类型错误:无效的论证,而不是字符串或列

类型错误:无效的论证,而不是字符串或列
EN

Stack Overflow用户
提问于 2022-05-02 14:18:44
回答 1查看 183关注 0票数 0

我试图做一些源,以目标测试在火星雨。我要做的第一部分是使用精益六西格玛方法对列进行计数,以确保列中的差异小于3/1000000。但是,当我运行这个程序时,if语句会抛出一个:

TypeError:无效论证,而不是字符串或列:-276244类型类型.对于列文字,请使用“lit”、“数组”、“struct”或“create_map”函数。

有人能帮忙吗?

代码语言:javascript
运行
复制
import pyspark.sql.functions as f
from pyspark.sql.types import *

good_fields = []
bad_fields = {}
count_issues = {}


columns = list(spark.sql('show columns from tu_historical').toPandas()['col_name'])

for col in columns: 
   print(col)
   df = spark.sql(f'select pid,fnum,{col} from historical_clean')
   df1 = spark.sql(f'select pid,fnum,{col} from historical1')
   
   #count issue testing
   if abs(df1.count()-df.count()) > df1.count()*.000003:
      count_issues[col] = df1.count()-df.count()

   test_df = df.join(df1,(df.num == df1.file) & (df1.pid == df.pid),'left').filter(df1[col]!=df[col])
EN

回答 1

Stack Overflow用户

发布于 2022-05-02 14:33:12

似乎你的columns有一个奇怪的价值。

您可能需要使用它来获取列名:

代码语言:javascript
运行
复制
columns = spark.sql('select * from tu_historical limit 0').columns
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72088067

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档