I have a dataframe with as many as 10 million records. How can I get a count quickly? df.count
is taking a very long time.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
It's going to take so much time anyway. At least the first time.
One way is to cache the dataframe, so you will be able to more with it, other than count.
E.g
df.cache()
df.count()
Subsequent operations don't take much time.
回答2:
file.groupBy("<column-name>").count().show()