PyCharm显示没有 pandas 输出 [英] PyCharm shows no output from pandas

查看:150
本文介绍了PyCharm显示没有 pandas 输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请放心,这是我尝试使用python的第一天,我已经在设置环境方面遇到问题.

Please go easy on me, its my first days trying to use python and I already have problem with setting up enviroment.

当我将IDLE与代码一起使用时:

When I use IDLE with code:

import pandas as pd

column_names = ["a,b"]
dataset = pd.read_csv('abdataset', names = column_names, index_col = False)


dataset

很好地显示了整个数据集.

shows the whole dataset in quite good way.

每当我在PyCharm上尝试相同的代码并在控制台上进入RUN时,我只能看到

Whenever when I try same code on PyCharm and go RUN on the console I can only see

以退出代码0结束的过程

Process finished with exit code 0

有什么方法可以配置运行控制台以像IDLE一样显示输出吗?

Is there any way to configure run console to show output like IDLE do?

推荐答案

这确实不是PyCharm的特定行为.

It is really not PyCharm specific behavior.

Python是一种解释的语言,即e.它会在您编写命令时立即执行每个命令,并按 Enter 键确认.一个命令接一个.

Python is an interpreted language, i. e. it executes every command immediately as you write it and confirm it with the Enter key. One command after the other.

但是-与其他解释语言一样-您还有另一种选择:将所有命令预先写入文本文件,然后要求Python以批量方式执行 -在另一个命令之后再次一个命令,但速度非常快.

But - as in other interpreted languages - you have another option: Write in advance all your commands into a text file and then ask Python to perform them as a batch - again one command after the other, but very fast.

first 情况下-按下 Enter 键后立即执行,可以很容易地通过编写它们-然后Python以标准(有时很难看)的形式显示它们.它是在 Python控制台环境中执行的,该环境也可以在PyCharm IDE中使用(例如,从菜单View | Tool Windows | Python console中获得).

In the first case - execution immediately after pressing the Enter key, it is comfortable to find of the value of a variable (or of an expression) by simply writing them - and Python display it in the standard (sometimes ugly) form. It is performed in the Python console environment, available in PyCharm IDE, too (e. g. from menu View | Tool Windows | Python console).

second 情况下(命令的批处理),它不太舒服,因为命令以非常快速的顺序执行,并且您通常无法确定哪个输出值对应于此外,如果您经常在监视器上看不到命令​​,则使用哪个变量.因此,在这种情况下(启动.py.pyc文件),不使用此方法,而是使用print命令(Python 2)或print()函数(Python 3)显式打印它们.在PyCharm IDE中,您可以按照以下步骤执行此操作:通过从项目中运行相应的 Python文件.

In the second case (the batch processing of commands) it would be not so comfortable, as commands are executed in a very fast sequence and you are generally not able to tell which output value corresponds to which variable, moreover if you often don't see your commands on your monitor. So in this case (launching a .py or .pyc file) this approach is not used and you have print them explicitely with the print command (Python 2) or print() function (Python 3). In PyCharm IDE you perform this action as you did: By running the appropriate Python file from your project.

因此您在PyCharm中有2种可能性:

So you have 2 possibilities in PyCharm:

  1. 使用 Python控制台来编写所有命令,一个接一个地-使用或不使用使用print命令/print()函数.
  2. 运行 Python文件(如您所做的那样),但使用明确打印要显示的内容.
  1. Use Python Console for writing all your commands, one after the other - with or without the use of the print command / print() function.
  2. Run a Python file (as you did) but with explicitly printing what you wanted to be displayed.


注意:


Note:

在空闲状态下,您具有相同两种可能性,并且具有相同行为:

In the IDLE you have the same 2 possibilities with the same behavior:

    启动空闲后立即
  • 1 st
  • 打开/创建Python文件并通过 F5 键启动它后,
  • 2 nd .
  • 1st immediately after starting the IDLE,
  • 2nd after opening / creating a Python file and launching it by F5 key.

这篇关于PyCharm显示没有 pandas 输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆