python 数据显示不完整 有省略号_python pandas之Dataframe的数据print输出显示为…省略号…

那么可以添加:

pandas.set_option(‘display.max_rows’,None)

这样就可以显示全部数据

同样,某一列比如url太长 显示省略号 也可以设置。

pd.set_option(‘display.max_colwidth’,500)

下面以爬取统计之家历史文章为例

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

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

Original: https://blog.csdn.net/weixin_39766910/article/details/113642403
Author: weixin_39766910
Title: python 数据显示不完整 有省略号_python pandas之Dataframe的数据print输出显示为…省略号…

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/679667/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球