-1

How to select or drop a designated row in pyspark dataframe? such as drop third row in dataframe

wa007
  • 105
  • 8
  • Possible duplicate of [How take a random row from a PySpark DataFrame?](https://stackoverflow.com/questions/34003314/how-take-a-random-row-from-a-pyspark-dataframe) – Gábor Bakos Nov 17 '19 at 16:03

1 Answers1

0

You can use where or filter functions to achieve this as shown below:-

df.filter($"age" > 15)
df.where($"age" > 15)

Update to drop by column index

val col = df.columns
val n   = df.columns.length 
val toBeDropped = n-1 // to drop last column  and so on..
val oldDf = df.drop(col(ToBeDropped ))  
Community
  • 1
  • 1
Jayadeep Jayaraman
  • 2,747
  • 3
  • 15
  • 26