Reputation: 21
I have a CSV file with the stocks of the BEL-20 and I need to write a function that will give me the graph of the values of a single stock. That single stock is defined by the Ticker word, for example Ticker = TNET is Telenet, so I need to make a graph with the stocks from Telenet. The values are all in the CSV file i got. The x and y axis where given by my teacher. Thanks in advance.
def graph(Ticker):
aandeel = pd.read_csv("beurskoersen.csv", sep=";", encoding='latin-1')
xAs = aandeel.columns[2:26]
yAs = aandeel.iloc[0,2:26]
plt.plot(xAs, yAs)
plt.legend()
plt.show()
Upvotes: 2
Views: 167
Reputation: 762
After reading the data to a dataframe, you can filter it with the needed value.
aandeel = pd.read_csv("beurskoersen.csv", sep=";", encoding='latin-1')
aandeel_filtered = aandeel[aandeel['Ticker'] == Ticker]
Upvotes: 1