Getting the count of records in a data frame quickly

不羁岁月 提交于 2019-12-04 02:49:30

问题


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()


来源:https://stackoverflow.com/questions/39357238/getting-the-count-of-records-in-a-data-frame-quickly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!