我有这个脚本:
# coding=utf8
import pandas as pd
import matplotlib.pyplot as plt
x = pd.read_csv(r'C:\Users\user\Desktop\201_b.csv', sep = ',', encoding = "utf-8")
passw = input('Password').upper()
if passw == 'A':
df = x[x['project'].str.contains('ek')]
#print(df)
plt.figure(figsize=(20,10))
plt.bar(df['user'], df['dates'], color="blue")
plt.show()
elif passw =='B':
df = x[x['project'].str.contains('yf')]
我输入了cmd:python file.py
并且该程序似乎先运行然后停止。在matplotlib
行之前,一切正常。现在,它甚至不要求输入。
我什至尝试过:
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame({'number': [10,34,56,45,51],'user':['user1','user2','user3','user4','user1']})
plt.bar(df['user'], df['number'], color="blue", linewidth =2, edgecolor='black' , alpha = 0.2)
plt.show()
x=input() #to deter it from closing - but no effect at all.
这更简单,并且执行相同的操作。运行,然后什么也没有。没有显示图像。
答案 0 :(得分:0)
x = pd.read_csv(“ C:\ Users \ user \ Desktop \ 201_b.csv”,sep =“,”,编码=“ utf-8”),您可以这样尝试而无需使用r
在文件路径之前。