【发布时间】:2017-10-10 03:01:15
【问题描述】:
我有一个DataFrame,我想使用pd.Series.value_counts() 显示某个Series 中某些值的频率。
问题是我只在输出中看到截断的结果。我正在 Jupyter Notebook 中编码。
我尝试了几种方法都不成功:
df = pd.DataFrame(...) # assume df is a DataFrame with many columns and rows
# 1st method
df.col1.value_counts()
# 2nd method
print(df.col1.value_counts())
# 3rd method
vals = df.col1.value_counts()
vals # neither print(vals) doesn't work
# All output something like this
value1 100000
value2 10000
...
value1000 1
目前我用的是这个,但是比较麻烦:
print(df.col1.value_counts()[:50])
print(df.col1.value_counts()[50:100])
print(df.col1.value_counts()[100:150])
# etc.
另外,我已经阅读了this 相关的 Stack Overflow 问题,但没有发现它有帮助。
那么如何停止输出截断的结果呢?
【问题讨论】: