Reputation: 561
I have a column['signal'] which composed of 500 ndarray data in each row. The length of each row is same. I would like to pick one row and plot it into picture. I tried something like data.reshape((1,-1)), but it did not work. I found many solutions on the net, but more error messages appeared. So how can I:
Here is a toy data sample:
' 19.35983', ' 19.33365', ' 19.30945', ' 19.3211',
' 19.34946', ' 19.37268', ' 19.38763', ' 19.4', ' 19.4063',
' 19.41592', ' 19.97250', ' 19.4294', ' 19.4368', ' 19.44623',
' 19.4646', ' 19.47464', ' 19.485', ' 19.4948', ' 19.50592',
' 19.51727', ' 19.51672', ' 19.5159', ' 19.52573'
If you can't use this data, please take any data that you believe it will help! Thank you!
Upvotes: 0
Views: 737
Reputation: 561
Thanks to @TME, I think I get some sort of images:
import numpy as np
import matplotlib.pyplot as plt
data = [' 19.35983', ' 19.33365', ' 19.30945', ' 19.3211']
lst = [float(item) for item in data]
array = np.reshape(lst, (-1,1))
plt.figure(figsize=(30,15))
plt.plot(array)
plt.ylabel('some numbers')
plt.show()
This may not be the right answer yet. If you know how to do it better or how to plot all images from that column (one row one image), please kindly advice. Thank you!
Upvotes: 0
Reputation: 129
Your data seems to be in string format, so try to convert before reshaping:
import numpy as np
data = [' 19.35983', ' 19.33365', ' 19.30945', ' 19.3211']
lst = [float(item) for item in data]
array = np.reshape(lst, (2,2))
Upvotes: 1