选择在python exec文件中导入CSV文档

时间:2020-08-15 11:25:43

标签: python user-interface data-visualization python-import import-csv

我和我的团队刚刚制作了一个用Python编写的基本可执行文件,您可以在其中选择使用同一数据框显示不同类型的图。 我们希望将我们的项目带到下一步,即制作一个名为“导入CSV文件”的附加选项卡,该选项卡使用户可以导入所需的文件并基于该文件进行绘图。 我们仍然是初学者,并正在寻找有关查找位置的指南,以实现这一目标。

GUI如下所示:

enter image description here

还有一些用于定义绘图的代码

def BarChart():
df = pd.read_csv(r"G:\Python Programming\Workspace\Example.csv")
plt.style.use('ggplot')
x = df['Gross Production per stage (m3/day)'].head(12)
y = df['Proppant Pumped(t)'].head(12)
width = 0.25
mean = df['Gross Production per stage (m3/day)'].mean()
median = df['Proppant Pumped(t)'].median()
day = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
day = np.arange(len(day))
plt.bar(day, x,width = width, color = 'steelblue',linewidth=1.5,linestyle = '--', label = 'Gross Production per stage (m3/day)')
plt.xlabel('Day')
plt.title('Boldesti 98 well')
plt.axhline(mean, color='steelblue', linestyle='--', alpha = 0.60, label = 'The average gross production per stage')
plt.bar(day + width , y,color = '#444444', width = width ,linewidth=1.5, label = 'Proppant Pumped (t)')
plt.legend()
plt.grid(True)
plt.savefig('plot.png')
plt.show()

我们想到的是创建一种算法,当导入CSV文件时,该算法会自动使用新代码更改代码中整个图的数据框的目录路径。 例如df=pd.read_csv(r" new path\File.csv")

我们非常感谢您的帮助。

0 个答案:

没有答案
相关问题