I have pandas data frame
data=df.loc[[0]]
print(data)
0 3.5257,3.5257,3.5257000000000005,3.5257,3.5257...
Name: testdata, dtype: object
I need to convert it to numpy array and want to plot the figure
You can use the .values attribute of the dataframe to convert it to a numpy array, and then use the numpy array to plot the figure. Here's an example:
import matplotlib.pyplot as plt
data = df.loc[[0]].values[0]
plt.plot(data)
plt.show()
Note that in the above code, df.loc[[0]].values[0] is used to extract the numpy array from the dataframe, as the output of df.loc[[0]] is still a dataframe. You can also use the .to_numpy() method to convert the dataframe to numpy array.
data = df.to_numpy()
plt.plot(data)
plt.show()
Also make sure that you have the matplotlib library imported and the data is of numerical values, otherwise you will get an error while plotting.