Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pyspark add new row to dataframe

I am trying to add a new row to dataframe but cant.

my code:

newRow = Row(id='ID123')
newDF= df.insertInto(newRow)
 or 
newDF= df.union(newRow)

errors:

AttributeError: _jdf

AttributeError: 'DataFrame' object has no attribute 'insertInto'
like image 520
HilaD Avatar asked Nov 29 '17 15:11

HilaD


1 Answers

Simple way to add row in dataframe using pyspark

newRow = spark.createDataFrame([(15,'Alk','Dhl')])
df = df.union(newRow)
df.show()
like image 117
Alkesh Mahajan Avatar answered Oct 03 '22 04:10

Alkesh Mahajan