Recently I worked on outputting a graph from a csv file with python. I'm new to pandas and matplotlib and it took me a while, so I'll summarize them briefly for future speedups.
input_csv_data.csv
No,Value
1,12
2,7
3,-19
4,28
5,60
import pandas as pd
import matplotlib.pyplot as plt
input_csv = pd.read_csv('./input_csv_data.csv')
first_column_data = input_csv[input_csv.keys()[0]]
second_column_data = input_csv[input_csv.keys()[1]]
plt.xlabel(input_csv.keys()[0])
plt.ylabel(input_csv.keys()[1])
plt.plot(first_column_data, second_column_data, linestyle='solid', marker='o')
plt.show()
--matplotlib official documentation https://matplotlib.org/3.3.3/api/_as_gen/matplotlib.pyplot.plot.html
Recommended Posts