0

I have a list of lists:

[['-49.20960' '35.91628' '-5.33521' '0.28950' '-0.00648' '0.00005' '1265']
 ['980.39881' '-874.95436' '153.33177' '-9.66707' '0.24657' '-0.00189'
  '119']
 ['-1824.01669' '973.09890' '-83.42090' '0.61490' '0.08083' '-0.00103'
  '240']
 ['189.33856' '-124.41292' '16.57153' '-0.77300' '0.01374' '-0.00007'
  '464']
 ['-3576.38367' '2577.36853' '-363.74838' '17.56082' '-0.27816' '0.00146'
  '206']
 ['-2988.77595' '1610.00929' '-148.44053' '2.44854' '0.07572' '-0.00114'
  '94']
 ['133.80111' '-86.16133' '11.20358' '-0.55227' '0.01288' '-0.00009' '25']
 ['1373.10186' '-1031.07001' '157.43685' '-8.66944' '0.19014' '-0.00128'
  '281']]

which, with pandas, I read as dataframe, and want to plot:

  fdata = pandas.DataFrame(data=coffs)  # Coffs is the list shown above
  fdata.columns = pname
  print(fdata)
  fdata.plot(kind='line', subplots=True, layout=(3, 2), sharex=False, sharey=False)
  plt.show()
  scatter_matrix(fdata)
  plt.show()

Which prints the dataframe fdata properly, as:

            c0           c1          c2        c3        c4        c5        C6
0    -49.20960     35.91628    -5.33521   0.28950  -0.00648   0.00005      1265
1    980.39881   -874.95436   153.33177  -9.66707   0.24657  -0.00189       119
2  -1824.01669    973.09890   -83.42090   0.61490   0.08083  -0.00103       240
3    189.33856   -124.41292    16.57153  -0.77300   0.01374  -0.00007       464
4  -3576.38367   2577.36853  -363.74838  17.56082  -0.27816   0.00146       206
5  -2988.77595   1610.00929  -148.44053   2.44854   0.07572  -0.00114        94
6    133.80111    -86.16133    11.20358  -0.55227   0.01288  -0.00009        25
7   1373.10186  -1031.07001   157.43685  -8.66944   0.19014  -0.00128       281

The line fdata.plot(kind='line', subplots=True, layout=(3, 2), sharex=False, sharey=False)

gives error:

TypeError: no numeric data to plot

and the line scatter_matrix(fdata) gives error:

ValueError: Number of columns must be > 0, not 0

What is going wrong here?

1 Answer 1

1

The big hint is in your error message.

TypeError: no numeric data to plot

Your list has all strings, but the plotting code needs numbers. So before your plot commands, you should convert everything.

fdata = fdata.astype(float)

Then you are ready for plotting. To get everything fully working, I also had to change the layout from (3, 2) to (4, 2) to accommodate the 7 columns from c0 to c6.

fdata.plot(kind='line', subplots=True, layout=(4, 2), sharex=False, sharey=False)

working plot

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.