Plotting many columns from a csv file

烂漫一生 提交于 2021-02-11 15:58:55

问题


Imagine I have a very big csv file with 500 rows and 500 columns. Part of the data shown : a small section of my data

I cannot delete the first couple of rows from my file but I can omit them using "skiprows" while reading the file.

Then I want to plot my data and all methods that I try fail. I actually get a plot if I just use 'plot()" command but what I want is to have the first column as my x data and the rest of 499 columns as my y data. Could you please help me with this?


回答1:


If df is your DataFrame and the first column is named x-data, then you can plot all other columns vs x-data like so:

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
df.iloc[:i+1,:].plot(x='x-data', ax=ax)


来源:https://stackoverflow.com/questions/62036205/plotting-many-columns-from-a-csv-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!