I have the following element:
a = Row(ts=1465326926253, myid=u'1234567', mytype=u'good')
The Row is of spark data frame Row class. Can I append a new field to a, so a would look like:
a = Row(ts=1465326926253, myid=u'1234567', mytype=u'good', name = u'john')
Thanks!
You cannot add new field to the
Row
.Row
is a subclass oftuple
and Python
tuples
are immutable. All you can do is create a new one:Please note that
Row
keeps it fields sorted by name.Here is an updated answer that works. First you have to create a dictionary then update the dict and then write it out to a pyspark Row.
Code is as follows: