0
저는 두 가지 문제가있는 첫 번째 불꽃 프로젝트에서 pyspark를 처음 사용하고 있습니다.) pyspark 데이터 프레임의 값 바꾸기
Code:
from pyspark import SparkConf, SparkContext
from pyspark.sql.functions import *
from pyspark.sql import Row, HiveContext, SQLContext, Column
from pyspark.sql.types import *
df = hive_context.table("db_new.temp_table")
df.select("col1").fillna(df.select("col1").mean())
***AttributeError: 'DataFrame' object has no attribute 'mean'***
평균
같이 집계 값 내 스파크 dataframe 어떤 도움이 크게 인식되는 값을 대체 할 수없는
df["col1"].show()
***TypeError: 'Column' object is not callable***
B를 사용하여 열을 참조
a) 수 없다!
는 업데이트 : 나는 아래의 코드를 시도했지만 다른 오류를 반환합니다.df.withColumn("new_Col", when("ColA".isNull,df.select(mean("ColA"))
.first()(0).asInstanceOf[Double])
.otherwise("ColA"))
AttributeError: 'str' object has no attribute 'isNull'
감사합니다! 그게 내 첫 번째 문제를 해결했다. 제 2의 제안? – pysparker
미안하지만 두 번째 부분을 보지 못했습니다. 두 번째 부분이 귀하의 질문에 대한 의견에 답변 된 것 같습니다. – ags29