python 数据显示不完整 有省略号_python pandas之Dataframe的数据print输出显示为...省略号...
pandas.set_option() 可以設置pandas相關的參數(shù),從而改變默認參數(shù)。 打印pandas數(shù)據(jù)事,默認是輸出100行,多的話會輸出….省略號。
那么可以添加:
pandas.set_option('display.max_rows',None)
這樣就可以顯示全部數(shù)據(jù)
同樣,某一列比如url太長 顯示省略號 也可以設置。
pd.set_option('display.max_colwidth',500)
下面以爬取統(tǒng)計之家歷史文章為例
# encoding: utf-8
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import pandas as pd
from lxml import etree
import requests
import re
url="https://cosx.org/archives/"
html=requests.get(url).content
selector=etree.HTML(html)
# print html
date=[]
url_list=[]
title=[]
date1=re.findall('(.*?)',html,re.S)
for each in date1:
# print each
date.append(each)
url_list1=selector.xpath('/html/body/p/article/main/ul/li/a/@href')
for each in url_list1:
# print each
# print "https://cosx.org"+str(each)
url_list.append("https://cosx.org" + str(each))
title1 = selector.xpath('/html/body/p/article/main/ul/li/a/text()')
for each in title1:
# print each
title.append(each)
print len(url_list),len(date),len(title)
pd.set_option('display.max_rows',None)
pd.set_option('display.max_colwidth',500)
df=pd.DataFrame({"日期":date,"標題":title,"鏈接":url_list})
print df
如您對本文有疑問或者有任何想說的,請點擊進行留言回復,萬千網(wǎng)友為您解惑!
總結
以上是生活随笔為你收集整理的python 数据显示不完整 有省略号_python pandas之Dataframe的数据print输出显示为...省略号...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: sar adc的常用指标(二)
- 下一篇: gae mysql_国内几大云服务引擎