pandas 显示代码片段和输出
示例
有两种流行的选择:
ipython表示法:
In [11]: df = pd.DataFrame([[1, 2], [3, 4]]) In [12]: df Out[12]: 0 1 0 1 2 1 3 4
或者(更简洁地在python文档中流行)并且更简洁:
df.columns # Out: RangeIndex(start=0, stop=2, step=1)
df[0]
# Out:
# 0 1
# 1 3
# Name: 0, dtype: int64
for col in df:
print(col)
# prints:
# 0
# 1通常,这对于较小的示例更好。
注意:输出和打印之间的区别。ipython明确了这一点(打印在返回输出之前发生):
In [21]: [print(col) for col in df] 0 1 Out[21]: [None, None]
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下