Login
Remember
Register
Questions
Unanswered
Ask a Question
Blog
Tutorials
Interview Questions
Ask a Question
community
Big Data Hadoop & Spark
Spark - extracting single value from DataFrame
Spark - extracting single value from DataFrame
0
votes
1
view
asked
Jul 13, 2019
in
Big Data Hadoop & Spark
by
Aarav
(
11.5k
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?
apache-spark
dataframe
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
Jul 16, 2019
by
Amit Rawat
(
32.5k
points)
I will suggest you to use
head()
df.head().getInt(0)
You can also use
first()
df.first().getInt(0)
Please
log in
or
register
to add a comment.
Related questions
0
votes
1
answer
Spark add new column to dataframe with value from previous row
asked
Jul 15, 2019
in
Big Data Hadoop & Spark
by
Aarav
(
11.5k
points)
apache-spark
dataframe
0
votes
1
answer
Dataframe sample in Apache spark | Scala
asked
Jul 28, 2019
in
Big Data Hadoop & Spark
by
Aarav
(
11.5k
points)
apache-spark
dataframe
sample
0
votes
1
answer
How to exclude multiple columns in Spark dataframe in Python
asked
Jul 17, 2019
in
Big Data Hadoop & Spark
by
Aarav
(
11.5k
points)
apache-spark
dataframe
0
votes
1
answer
How to check if spark dataframe is empty
asked
Jul 9, 2019
in
Big Data Hadoop & Spark
by
Aarav
(
11.5k
points)
apache-spark
dataframe
0
votes
1
answer
Create Spark DataFrame. Can not infer schema for type: <type 'float'>
asked
Jul 8, 2019
in
Big Data Hadoop & Spark
by
Aarav
(
11.5k
points)
apache-spark
dataframe
python
Welcome to Intellipaat Community. Get your technical queries answered by top developers !
Categories
All categories
Python
(3.2k)
Java
(1.6k)
SQL
(1.4k)
Linux
(297)
Big Data Hadoop & Spark
(1.1k)
Data Science
(2.5k)
R Programming
(844)
C Programming
(22)
DevOps and Agile
(2.7k)
Docker
(55)
AI and Deep Learning
(1.3k)
Machine Learning
(1.1k)
AWS
(2.2k)
Azure
(1.4k)
GCP
(206)
RPA
(617)
Selenium
(162)
Blockchain
(405)
Salesforce
(706)
Others
(70)
BI
(1.7k)
IoT
(24)
Web Technology
(1.4k)
Cyber Security
(241)
Digital Marketing
(209)
Technology Trends
(58)
SEO
(104)
Informatica
(13)
...