【发布时间】:2018-11-03 13:12:36
【问题描述】:
我正在关注 Google 的 Machine Learning Crash Course,以便继续使用 TensorFlow。但是,当我尝试执行 First Steps With TensorFlow 中的代码时,以下行没有输出:
california_housing_dataframe.describe()
这是我的完整代码,以防有帮助:
import math
from IPython import display
from matplotlib import cm
from matplotlib import gridspec
from matplotlib import pyplot as plt
import numpy as np
import pandas as pd
from sklearn import metrics
import tensorflow as tf
from tensorflow.python.data import Dataset
tf.logging.set_verbosity(tf.logging.ERROR)
pd.options.display.max_rows = 10
pd.options.display.float_format = '{:.1f}'.format
california_housing_dataframe = pd.read_csv("https://storage.googleapis.com/mledu-datasets/california_housing_train.csv", sep=",")
california_housing_dataframe = california_housing_dataframe.reindex(np.random.permutation(california_housing_dataframe.index))
california_housing_dataframe["median_house_value"] /= 1000.0
california_housing_dataframe.describe()
到目前为止,我已经尝试了以下方法:
用python命令执行.py文件。
使用 ipython 命令执行 .py 文件。我还尝试使用参数 -i -c(即 ipython -i -c "%run filename.py")。
打开 ipython.exe 并使用 run 命令执行我的脚本。
打开ipython.exe,逐行复制代码。
除了上述之外,只有将每一行单独复制到 IPython 中才能得到正确的输出。有没有一种方法可以执行我的脚本而不必复制 IPython 中的每一行?
【问题讨论】:
-
如果不是在交互式控制台中而是在程序中,请尝试
print(california_housing_dataframe.describe()) -
谢谢,这似乎工作正常。
标签: python pandas tensorflow