如何解决如何在返回python主菜单之前显示绘图
它在我完成循环后显示条形图。如何在再次要求用户输入之前显示条形图?
解决方法
您必须要求 sns
显示情节:
def menu():
print('Please select one of the following options: \n')
print('1. income per country')
print('2. Marital status')
print('3. Income and education level')
print('4. food analysis')
print('5. Exit')
while True:
try:
option = int(input('Enter your option: '))
if option ==1:
eth = demo_data['country'].nunique()
print('Number of country in the dataset: ',eth)
print('Number of respondents per country: \n')
demo_data['country'].value_counts()
ax = sns.barplot(x = demo_data['Income'],y = demo_data['country'],data = demo_data[demo_data['Age '] > 20]);
ax.plot()
plt.show()
continue
except ValueError:
print("Sorry,I didn't understand that.")
continue
if option <= 0:
print("Sorry,your response must not be negative.")
continue
elif option >5:
print("Sorry,your response must be within the list range.")
continue
else:
break
menu()
给出
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。