我正在使用 Pandas、Excel 和 Matplotlib。该程序对存储在 Excel 中的数据执行一些操作并将它们保存在那里。接下来,它绘制数据。要绘制的数据由太多数组组成,如下所示:
x=list(excelfile['Дата'][2:3625])
y1=list(excelfile['a'][2:3625])
y2=list(excelfile['a1'][2:3625])
y3=list(excelfile['a1=f(b)'][2:3625])
y4=list(excelfile['c'][2:3625])
y5=list(excelfile['c=f(d)'][2:3625])
有什么方法可以手动设置单元格的范围 ([2:3625]),一劳永逸,而不必每次想使用不同的范围时都重写它
一般来说,如果你发现自己在做重复性的工作,你就需要变量和函数。例如
def getData(filename, startCell, endCell):
return list(excelfile[filename][startCell:endCell]
startCell = 2
endCell = 3625
x = getData('Дата', startCell, endCell)
# ...
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句