0

Currently I have this dataframe(df):

    +-------------------+--------+
    |       datetime_new|pkts_new|
    +-------------------+--------+
    |2018-01-04 00:00:00|    47.0|
    |2018-01-04 00:00:00|     1.0|
    |2018-01-04 00:00:00|     3.0|
    |2018-01-04 00:00:00|    40.0|
    |2018-01-04 00:01:00|     1.0|
    |2018-01-04 00:01:00|     1.0|
    |2018-01-04 00:01:00|     1.0|
    |2018-01-04 00:01:00|    49.0|
    |2018-01-04 00:01:00|    33.0|
    |2018-01-04 00:01:00|     2.0|
    +-------------------+--------+

`DataFrame[datetime_new: timestamp, pkts_new: double]`

type(t): <class 'pyspark.sql.dataframe.DataFrame'>

I want to plot a line chart where the x axis is datetime_new, and the y axis is pkts_new. However, when i used this command: plt.plot(df.select('datetime_new'),df.select('pkts_new')) , I will get the error message:ValueError: setting an array element with a sequence.

How do I plot a line chart for ?

Dominique
  • 16,450
  • 15
  • 56
  • 112
R_abcdefg
  • 145
  • 1
  • 11

1 Answers1

0

Convert array into list using list(myarray)

import matplotlib.pyplot as plt    
plt.plot(data_time,time)
plt.show()
raunak rathi
  • 95
  • 1
  • 9