简体   繁体   English

我如何使该程序在PyCharm中工作

[英]How do I make this program work in PyCharm

I am using pandas to search an excel file and return the price of the corresponding search. 我正在使用熊猫搜索Excel文件并返回相应搜索的价格。 It runs just file in the Command Prompt, but does not when I try to run it in the IDE PyCharm. 它仅在命令提示符中运行文件,而当我尝试在IDE PyCharm中运行该文件时则不运行。

I believe that it isn't doing anything with the line 我相信它没有做任何事情

df[Number][['Part Number', 'Price']]

import pandas as pd
df = pd.read_excel(r'C:\Users\Matthew\Desktop\Test.xls')
print("EXIT to end")
PN = input('Enter PN: ')
Number = df['Part Number'] == PN
df[Number][['Part Number', 'Price']]

This should provide an output that gives me the Part number and Price but instead it just ends and doesn't return anything where as in the Command Prompt it was returning the correct values. 这应该提供给我零件号和价格的输出,但是它只是结束并且不返回任何内容,如命令提示符中返回的正确值一样。

You need to add a print() statement at the last line of code in order to get the desired output printed. 您需要在代码的最后一行添加print()语句,以获取所需的输出。

The line 线

df[Number][['Part Number', 'Price']]

will become 会变成

print(df[Number][['Part Number', 'Price']])

Note: Summarized solutions from comments to ensure question can be marked as solved. 注意:注释中总结的解决方案可确保将问题标记为已解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM