每当打印系列时,都在底部摆脱系列信息

时间:2019-07-16 17:49:34

标签: python pandas

我正在打印摘要统计信息,但是每次我从系列中打印数据时,都会得到此页脚:Name: School DBN, dtype: int64。由于我为一列打印了一些不同的统计信息,所以这会使我的输出混乱。

例如,这里我按频率打印出一列中显示的所有值,但是如果值太多,也将截断列表。

    for keys,vals in hist_col_vals.items():
        print(keys)
        print("# of Returned Values: " + str(vals.count()))
        try:
            if vals.count() > 20:
                raise TooLongError
            print("All Returned Values: " + '\n' + str(vals))
        except TooLongError:
            print("Over 10 values, returning sample values from beginning and end:")
            print("Most Frequent:")
            print(vals[0:5])
            print("Least Frequent")
            print(vals[-5:])

我的读数的输出是这样的。请注意,Name: School DBN, dtype: int64使读数更加混乱:


School DBN
# of Returned Values: 977
Over 10 values, returning sample values from beginning and end:
Most Frequent:
20K505    11
22K535    11
30Q502    11
11X455    11
02M507    11
Name: School DBN, dtype: int64
Least Frequent
13K492    1
84K742    1
02M217    1
23K518    1
29Q355    1 
Name: School DBN, dtype: int64

0 个答案:

没有答案