Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Big Data Hadoop & Spark by (11.4k points)
I have a Spark DataFrame query that is guaranteed to return single column with single Int value. What is the best way to extract this value as Int from the resulting DataFrame?

1 Answer

0 votes
by (32.3k points)

I will suggest you to use head()

df.head().getInt(0)

You can also use first()

df.first().getInt(0)

Browse Categories

...