I am currently trying to load a csv file of data into spyder and I just cant figure it out. Also my code below gets a value error stating "could not convert string to float:"
My Code:
import numpy as np
import matplotlib.pyplot as plt
data = np.loadtxt('magnet lab.csv',delimiter=',',skiprows=2)
kimberlite = np.array(data[:,0])
forcekimberlite = np.array(data[:1])
plt.scatter(kimberlite,forcekimberlite,s=5,c='red',marker='o')
plt.xlim(0,5)
plt.xlabel('distance from center of magnet to kimberlite')
plt.ylabel('Force')
plt.title('Kimberlite results')
plt.show()
试试这个来加载 csv 文件。
data = np.genfromtxt('magnet lab.csv',delimiter=',')
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.