Spark DataFrame是否等效于Pandas Dataframe`.iloc()`方法? [英] Spark DataFrame equivalent to Pandas Dataframe `.iloc()` method?
本文介绍了Spark DataFrame是否等效于Pandas Dataframe`.iloc()`方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法可以使用整数来按位置引用Spark DataFrame列?
Is there a way to reference Spark DataFrame columns by position using an integer?
模拟熊猫DataFrame操作:
Analogous Pandas DataFrame operation:
df.iloc[:0] # Give me all the rows at column position 0
推荐答案
相当于Python df.iloc
的收集器
The equivalent of Python df.iloc
is collect
PySpark示例:
X = df.collect()[0]['age']
或
X = df.collect()[0][1] #row 0 col 1
这篇关于Spark DataFrame是否等效于Pandas Dataframe`.iloc()`方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文