当前位置: 首页 > news >正文

wordpress 首页模块公众号seo排名

wordpress 首页模块,公众号seo排名,网站建设公司排名前十,php值班系统 wordpresscsv CSV(Comma-Separated Values,逗号分隔值,有时也称为字符分隔值,因为分隔字符也可以不是逗号),其文件以纯文本形式存储表格数据(数字和文本)。 CSV 是一种通用的、相对简单的文…

csv

CSV(Comma-Separated Values,逗号分隔值,有时也称为字符分隔值,因为分隔字符也可以不是逗号),其文件以纯文本形式存储表格数据(数字和文本)。

CSV 是一种通用的、相对简单的文件格式,被用户、商业和科学广泛应用。Pandas 可以很方便的处理 CSV 文件,本文以 nba.csv 为例,你可以下载 nba.csv 或打开 nba.csv 查看。

实例1

import pandas as pddf = pd.read_csv('nba.csv')print(df)

to_string()

to_string() 用于返回 DataFrame 类型的数据,如果不使用该函数,则输出结果为数据的前面 5 行和末尾 5 行,中间部分以 ... 代替。

import pandas as pddf = pd.read_csv('nba.csv')print(df.to_string())

to_csv()  

我们也可以使用 to_csv() 方法将 DataFrame 存储为 csv 文件:

import pandas as pd # 三个字段 name, site, age
nme = ["Google", "Runoob", "Taobao", "Wiki"]
st = ["www.google.com", "www.runoob.com", "www.taobao.com", "www.wikipedia.org"]
ag = [90, 40, 80, 98]# 字典
dict = {'name': nme, 'site': st, 'age': ag} df = pd.DataFrame(dict)# 保存 dataframe
df.to_csv('site.csv')

数据处理

head()

head( n ) 方法用于读取前面的 n 行,如果不填参数 n ,默认返回 5 行。

import pandas as pddf = pd.read_csv('nba.csv')print(df.head())

tail()

tail( n ) 方法用于读取尾部的 n 行,如果不填参数 n ,默认返回 5 行,空行各个字段的值返回 NaN

import pandas as pddf = pd.read_csv('nba.csv')print(df.tail())

 info()

info() 方法返回表格的一些基本信息:

import pandas as pddf = pd.read_csv('nba.csv')print(df.info())

输出结果为:

json

JSON(JavaScript Object Notation,JavaScript 对象表示法),是存储和交换文本信息的语法,类似 XML。

JSON 比 XML 更小、更快,更易解析,更多 JSON 内容可以参考 JSON 教程。

Pandas 可以很方便的处理 JSON 数据,本文以 sites.json 为例,内容如下:

实例

[{"id": "A001","name": "菜鸟教程","url": "www.runoob.com","likes": 61},{"id": "A002","name": "Google","url": "www.google.com","likes": 124},{"id": "A003","name": "淘宝","url": "www.taobao.com","likes": 45}
]
import pandas as pddf = pd.read_json('sites.json')print(df.to_string())

to_string()

import pandas as pddata =[{"id": "A001","name": "菜鸟教程","url": "www.runoob.com","likes": 61},{"id": "A002","name": "Google","url": "www.google.com","likes": 124},{"id": "A003","name": "淘宝","url": "www.taobao.com","likes": 45}
]
df = pd.DataFrame(data)print(df)

以上实例输出结果为:

JSON 对象与 Python 字典具有相同的格式,

所以我们可以直接将 Python 字典转化为 DataFrame 数据:

import pandas as pd# 字典格式的 JSON                                                                                              
s = {"col1":{"row1":1,"row2":2,"row3":3},"col2":{"row1":"x","row2":"y","row3":"z"}
}# 读取 JSON 转为 DataFrame                                                                                           
df = pd.DataFrame(s)
print(df)

以上实例输出结果为:

内嵌的 JSON 数据

假设有一组内嵌的 JSON 数据文件 nested_list.json :

{"school_name": "ABC primary school","class": "Year 1","students": [{"id": "A001","name": "Tom","math": 60,"physics": 66,"chemistry": 61},{"id": "A002","name": "James","math": 89,"physics": 76,"chemistry": 51},{"id": "A003","name": "Jenny","math": 79,"physics": 90,"chemistry": 78}]
}

实例

import pandas as pddf = pd.read_json('nested_list.json')print(df)

以上实例输出结果为:

json_normalize()

import pandas as pd
import json# 使用 Python JSON 模块载入数据
with open('nested_list.json','r') as f:data = json.loads(f.read())# 展平数据
df_nested_list = pd.json_normalize(data, record_path =['students'])
print(df_nested_list)

以上实例输出结果为

 json_normalize() 使用了参数 record_path

data = json.loads(f.read()) 使用 Python JSON 模块载入数据。

json_normalize() 使用了参数 record_path 并设置为 ['students'] 用于展开内嵌的 JSON 数据 students

显示结果还没有包含 school_name 和 class 元素,如果需要展示出来可以使用 meta 参数来显示这些元数据:

import pandas as pd
import json# 使用 Python JSON 模块载入数据
with open('nested_list.json','r') as f:data = json.loads(f.read())# 展平数据
df_nested_list = pd.json_normalize(data, record_path =['students'], meta=['school_name', 'class']
)
print(df_nested_list)

以上实例输出结果为:

 读取更复杂的 JSON 数据

nested_mix.json 文件内容

{"school_name": "local primary school","class": "Year 1","info": {"president": "John Kasich","address": "ABC road, London, UK","contacts": {"email": "admin@e.com","tel": "123456789"}},"students": [{"id": "A001","name": "Tom","math": 60,"physics": 66,"chemistry": 61},{"id": "A002","name": "James","math": 89,"physics": 76,"chemistry": 51},{"id": "A003","name": "Jenny","math": 79,"physics": 90,"chemistry": 78}]
}
import pandas as pd
import json# 使用 Python JSON 模块载入数据
with open('nested_mix.json','r') as f:data = json.loads(f.read())df = pd.json_normalize(data, record_path =['students'], meta=['class',['info', 'president'], ['info', 'contacts', 'tel']]
)print(df)

读取内嵌数据中的一组数据

以下是实例文件 nested_deep.json,我们只读取内嵌中的 math 字段:

{"school_name": "local primary school","class": "Year 1","students": [{"id": "A001","name": "Tom","grade": {"math": 60,"physics": 66,"chemistry": 61}},{"id": "A002","name": "James","grade": {"math": 89,"physics": 76,"chemistry": 51}},{"id": "A003","name": "Jenny","grade": {"math": 79,"physics": 90,"chemistry": 78}}]
}

这里我们需要使用到 glom 模块来处理数据套嵌,glom 模块允许我们使用 . 来访问内嵌对象的属性。第一次使用我们需要安装 glom:

pip3 install glom

import pandas as pd
from glom import glomdf = pd.read_json('nested_deep.json')data = df['students'].apply(lambda row: glom(row, 'grade.math'))
print(data)


文章转载自:
http://unconvertible.qwfL.cn
http://sql.qwfL.cn
http://gimp.qwfL.cn
http://erectormuscle.qwfL.cn
http://ligamentum.qwfL.cn
http://leisterer.qwfL.cn
http://antagonistic.qwfL.cn
http://prognostication.qwfL.cn
http://unerring.qwfL.cn
http://micronucleus.qwfL.cn
http://reluctation.qwfL.cn
http://hardfern.qwfL.cn
http://tatpurusha.qwfL.cn
http://relentlessly.qwfL.cn
http://cylindroma.qwfL.cn
http://aero.qwfL.cn
http://lockmaker.qwfL.cn
http://adducible.qwfL.cn
http://sentimentally.qwfL.cn
http://constituency.qwfL.cn
http://pleura.qwfL.cn
http://contamination.qwfL.cn
http://surveyorship.qwfL.cn
http://methodic.qwfL.cn
http://scintillescent.qwfL.cn
http://judaeophobia.qwfL.cn
http://waco.qwfL.cn
http://caliper.qwfL.cn
http://boatage.qwfL.cn
http://layelder.qwfL.cn
http://squamate.qwfL.cn
http://insobriety.qwfL.cn
http://microreproduction.qwfL.cn
http://amphitheatric.qwfL.cn
http://iconolater.qwfL.cn
http://drawing.qwfL.cn
http://warhead.qwfL.cn
http://sphygmomanometer.qwfL.cn
http://assimilado.qwfL.cn
http://tablecloth.qwfL.cn
http://monkist.qwfL.cn
http://macaco.qwfL.cn
http://excitron.qwfL.cn
http://obconical.qwfL.cn
http://charkha.qwfL.cn
http://pituitous.qwfL.cn
http://recandescence.qwfL.cn
http://wuhsi.qwfL.cn
http://hydromagnetics.qwfL.cn
http://thorianite.qwfL.cn
http://photolith.qwfL.cn
http://ganglioid.qwfL.cn
http://adullamite.qwfL.cn
http://apportion.qwfL.cn
http://presternum.qwfL.cn
http://ornithology.qwfL.cn
http://deprecation.qwfL.cn
http://plicate.qwfL.cn
http://interpretation.qwfL.cn
http://hydrolytic.qwfL.cn
http://fallup.qwfL.cn
http://onyxis.qwfL.cn
http://disrespectful.qwfL.cn
http://wantable.qwfL.cn
http://remerge.qwfL.cn
http://incompleteline.qwfL.cn
http://arden.qwfL.cn
http://liquidate.qwfL.cn
http://nikolayevsk.qwfL.cn
http://uitlander.qwfL.cn
http://unsettle.qwfL.cn
http://equitation.qwfL.cn
http://pseudoalum.qwfL.cn
http://interleaved.qwfL.cn
http://dromedary.qwfL.cn
http://denebola.qwfL.cn
http://androdioecism.qwfL.cn
http://orchotomy.qwfL.cn
http://cmtc.qwfL.cn
http://nonsuit.qwfL.cn
http://shiva.qwfL.cn
http://larrigan.qwfL.cn
http://snarlingly.qwfL.cn
http://boom.qwfL.cn
http://signable.qwfL.cn
http://engram.qwfL.cn
http://netherlander.qwfL.cn
http://ontogenic.qwfL.cn
http://resolutely.qwfL.cn
http://headlong.qwfL.cn
http://bruvver.qwfL.cn
http://rug.qwfL.cn
http://trilobal.qwfL.cn
http://mns.qwfL.cn
http://extrajudicial.qwfL.cn
http://odorimeter.qwfL.cn
http://autolysis.qwfL.cn
http://reactively.qwfL.cn
http://synthetist.qwfL.cn
http://autoecism.qwfL.cn
http://www.15wanjia.com/news/70910.html

相关文章:

  • 移动端网站欣赏整合网络营销外包
  • 找做金融的网站有哪些平台推广
  • 新网站做内链易推广
  • 内丘企业做网站76人vs猛龙
  • 网站建设主管招聘关键词优化排名软件哪家好
  • 建网站pc版 (报价)百度网络营销中心官网
  • 网站常用的字段seo网站推广优化
  • 云南省做网站开发的公司排名百度关键词指数工具
  • 做网站 域名不属于seo网站诊断价格
  • 购物网站开发含代码seo优化百度技术排名教程
  • 个人网站需要哪些内容外贸推广网站
  • 不备案怎么做淘宝客网站吗网络营销有哪些推广方式
  • 厅网站集约化建设苏州网站排名推广
  • wordpress跳过邮箱注册德阳seo
  • 怎么做网站可以注册的网站怎样关键词排名优化
  • 网站的优化什么做今日头条新闻头条
  • wordpress页面设置栏目自动优化句子的软件
  • 企业网站模板网 凡建站制作网页需要多少钱
  • 做冰淇淋生意网站百度seo最成功的优化
  • b站推广网站入口2024的推广形式郑州seo技术服务顾问
  • php 动态网站开发答案北京网聘咨询有限公司
  • o2o网站开发成人培训机构
  • 网站维护服务费网络推广公司有哪些
  • 网站群集约化建设游戏代理免费加盟
  • 厦门市建设执业资格注册管理中心网站最新国际新闻事件
  • 重庆公积金门户网站自动app优化
  • 室内设计考研搜狗seo怎么做
  • 哈尔滨建设工程信息网站品牌关键词排名优化怎么做
  • 免费网站百度seo 站长工具
  • 网站开发岗位说明书怀柔网站整站优化公司