Aug-22-2020, 01:34 PM
I have a very simple code to plot. The data file consists of seven columns with values (not integers), and I wish to plot their division. This is the code:
import pandas as pd data = pd.read_csv('Co_foil_2.data',sep='\s+',header=None) data = pd.DataFrame(data) import matplotlib.pyplot as plt y = data[0] a = (data[1]/data[2]) b = (data[2]/data[2]) c = (data[3]/data[2]) d = (data[4]/data[2]) e = (data[5]/data[2]) f = (data[6]/data[2]) plt.plot(a, y,'r--') plt.plot(b, y,'b--') plt.plot(c, y,'g--') plt.plot(d, y,'y--') plt.plot(e, y,'m--') plt.plot(f, y,'k--') plt.legend() plt.show()However, this returns an error:
TypeError: unsupported operand type(s) for /: 'str' and 'str'From what I understand, the columns can't be divided for some reason; am I simply using a wrong command, or is there something more prominently wrong in the code?