Reputation: 51
I have a PySpark data frame which only contains one element. How can I extract the number from the data frame?
For the example, how can I get the number 5.0 from the PySpark data frame?
+-----------------+
| count |
+-----------------+
| 5.0 |
+-----------------+
Upvotes: 1
Views: 4095
Reputation: 24386
Several alternatives:
df.head()[0]
df.head().count
df.head()['count']
first
does the same, but head
is 1 letter shorter ;)
Upvotes: 1