I get this data from CSV file and i need to send this data to Server. But i need just value from this list.
{1: Row(Moid=1, Tripid='1', Tstart='2007-05-27', Tend='2007-05-27 08:36:47.846', Xstart='12785', Ystart='1308', Xend='12785', Yend='1308'), 2: Row(Moid=2, Tripid='10', Tstart='2007-05-27', Tend='2007-05-28 08:52:53.673', Xstart='9716', Ystart='-55', Xend='9716', Yend='-55')}
i want to get this
{ (1, 1, 2007-05-27, 2007-05-2708:36:47.846 , 12785, 1308, 12785, 1308)
(2, 10, 2007-05-27, 2007-05-2808:52:53.673 , 9716, -55, 9716, -55)
You can use rdd and a map function that converts the row to a tuple. I just used your first 3 values for an example implementation:
df = spark.createDataFrame([(1,"1",'2007-05-27'),(2,"10", "2007-05-27")], ['moid',"tripid","tstart"])
print df.rdd.map(lambda r: tuple(r)).collect()
Output would be a list of tuples:
[(1, u'1', u'2007-05-27'), (2, u'10', u'2007-05-27')]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.