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

网站做排名有用吗企业seo排名外包

网站做排名有用吗,企业seo排名外包,网站分几类,免费做网站建设对于我们日常的数据清理、预处理和分析方面的大多数任务,Pandas已经绰绰有余。但是当数据量变得非常大时,它的性能开始下降。 本文将介绍如何将日常的数据ETL和查询过滤的Pandas转换成polars。 图片 Polars的优势 Polars是一个用于Rust和Python的Data…

对于我们日常的数据清理、预处理和分析方面的大多数任务,Pandas已经绰绰有余。但是当数据量变得非常大时,它的性能开始下降。

本文将介绍如何将日常的数据ETL和查询过滤的Pandas转换成polars。

图片

Polars的优势
Polars是一个用于Rust和Python的DataFrame库。

Polars利用机器上所有可用的内核,而pandas使用单个CPU内核来执行操作。

Polars比pandas相对轻量级,没有依赖关系,这使得导入Polars的速度更快。导入Polars只需要70毫秒,而导入pandas需要520毫秒。

Polars进行查询优化减少了不必要的内存分配。它还能够以流方式部分或全部地处理查询。

Polars可以处理比机器可用RAM更大的数据集。

ETL
Extract, Transform, and Load (ETL)的过程是怎样的:

“提取、转换和加载(ETL)是将来自多个数据源的数据组合到称为数据仓库的过程。ETL使用一组业务规则来清理和组织原始数据,并为存储、数据分析和机器学习(ML)做好准备。可以通过数据分析解决特定的业务智能需求(例如预测业务决策的结果、生成报告、减少操作效率低下,等等)。(来源:AWS)

Polars和Pandas都支持从各种来源读取数据,包括CSV、Parquet和JSON。

df = pl.read_csv(‘data.csv’)
df = pl.read_parquet(‘data.parquet’)
df = pl.read_json(‘data.json’)
对于数据的读取方面和Pandas基本一致。

转换是ETL中最重要、最困难和最耗时的步骤。

polar支持Pandas函数的一个子集,所以我们可以使用熟悉的Pandas函数来执行数据转换。

df = df.select([‘A’, ‘C’])
df = df.rename({‘A’: ‘ID’, ‘C’: ‘Total’})
df = df.filter(pl.col(‘A’) > 2)
df = df.groupby(‘A’).agg({‘C’: ‘sum’})
这些Pandas函数都可以直接使用。

创建新列:

df = df.with_column(pl.col(‘Total’) / 2, ‘Half Total’)
处理空值:

df = df.fill_null(0)
df_filled = df.fill_null(‘backward’)
df = df.fillna(method=‘ffill’)
Dataframe 的合并

#pandas
df_join = pd.merge(df1, df2, on=‘A’)
#polars
df_join = df1.join(df2, on=‘A’)
连接两个DF

#pandas
df_union = pd.concat([df1, df2], ignore_index=True)
#polars
df_union = pl.vstack([df1, df2])
polar使用与Pandas相同的函数来将数据保存到CSV、JSON和Parquet文件中。

CSV

df.to_csv(file)

JSON

df.to_json(file)

Parquet

df.to_parquet(file)
最后,如果你还需要使用Pandas做一些特殊的操作,可以使用:

df.to_pandas()
这可以将polar的DF转换成pandas的DF。

最后我们整理一个简单的表格:

图片

数据的查询过滤
我们的日常工作中,数据的查询是最重要,也是用的最多的,所以在这里我们再整理下查询过滤的操作。

首先创建一个要处理的DataFrame。

pandas

import pandas as pd

read csv

df_pd = pd.read_csv(“datasets/sales_data_with_stores.csv”)

display the first 5 rows

df_pd.head()
图片

polars

import polars as pl

read_csv

df_pl = pl.read_csv(“datasets/sales_data_with_stores.csv”)

display the first 5 rows

df_pl.head()
图片

polars首先显示了列的数据类型和输出的形状,这对我们来说非常好。下面我们进行一些查询,我们这里只显示一个输出,因为结果都是一样的:

1、按数值筛选

pandas

df_pd[df_pd[“cost”] > 750]
df_pd.query(‘cost > 750’)

polars

df_pl.filter(pl.col(“cost”) > 750)
图片

2、多个条件查询

pandas和polar都支持根据多个条件进行过滤。我们可以用“and”和“or”逻辑组合条件。

pandas

df_pd[(df_pd[“cost”] > 750) & (df_pd[“store”] == “Violet”)]

polars

df_pl.filter((pl.col(“cost”) > 750) & (pl.col(“store”) == “Violet”))
图片

3、isin

pandas的isin方法可用于将行值与值列表进行比较。当条件包含多个值时,它非常有用。这个方法的polar版本是" is_in "。

pandas

df_pd[df_pd[“product_group”].isin([“PG1”, “PG2”, “PG5”])]

polars

df_pl.filter(pl.col(“product_group”).is_in([“PG1”, “PG2”, “PG5”]))
图片

4、选择列的子集

为了选择列的子集,我们可以将列名传递给pandas和polar,如下所示:

cols = [“product_code”, “cost”, “price”]

pandas (both of the following do the job)

df_pd[cols]
df_pd.loc[:, cols]

polars

df_pl.select(pl.col(cols))
图片

5、选择行子集

pandas中可以使用loc或iloc方法选择行。在polar则更简单。

pandas

df_pd.iloc[10:20]

polars

df_pl[10:20]
选择相同的行,但只选择前三列:

pandas

df_pd.iloc[10:20, :3]

polars

df_pl[10:20, :3]
如果要按名称选择列:

pandas

df_pd.loc[10:20, [“store”, “product_group”, “price”]]

polars

df_pl[10:20, [“store”, “product_group”, “price”]]
按数据类型选择列:

我们还可以选择具有特定数据类型的列。

pandas

df_pd.select_dtypes(include=“int64”)

polars

df_pl.select(pl.col(pl.Int64))
图片

总结
可以看到polar与pandas非常相似,所以如果在处理大数据集的时候,我们可以尝试使用polar,因为它在处理大型数据集时的效率要比pandas高,我们这里只介绍了一些简单的操作,如果你想了解更多,请看polar的官方文档:

https://pola-rs.github.io/polars-book/user-guide/coming_from_pandas.html


文章转载自:
http://theophany.pwrb.cn
http://interpolate.pwrb.cn
http://emigrator.pwrb.cn
http://apparent.pwrb.cn
http://biliverdin.pwrb.cn
http://greengrocery.pwrb.cn
http://subliminal.pwrb.cn
http://micromodule.pwrb.cn
http://incaution.pwrb.cn
http://climber.pwrb.cn
http://gauge.pwrb.cn
http://microtransmitter.pwrb.cn
http://philanthropic.pwrb.cn
http://cytotechnology.pwrb.cn
http://westernmost.pwrb.cn
http://laptev.pwrb.cn
http://machinist.pwrb.cn
http://phalera.pwrb.cn
http://abernethy.pwrb.cn
http://infrangibility.pwrb.cn
http://alcoholism.pwrb.cn
http://antipodes.pwrb.cn
http://microalloy.pwrb.cn
http://schizont.pwrb.cn
http://kerne.pwrb.cn
http://dipsophobia.pwrb.cn
http://piloting.pwrb.cn
http://hematophagous.pwrb.cn
http://tabefaction.pwrb.cn
http://chessylite.pwrb.cn
http://protoplast.pwrb.cn
http://grovel.pwrb.cn
http://spermatozoal.pwrb.cn
http://sardine.pwrb.cn
http://monopitch.pwrb.cn
http://conceptacle.pwrb.cn
http://muttonhead.pwrb.cn
http://groomsman.pwrb.cn
http://underutilize.pwrb.cn
http://acquisitive.pwrb.cn
http://pergola.pwrb.cn
http://daydream.pwrb.cn
http://megacorpse.pwrb.cn
http://clonidine.pwrb.cn
http://bachelorism.pwrb.cn
http://brent.pwrb.cn
http://chutzpa.pwrb.cn
http://scroticles.pwrb.cn
http://contrapuntist.pwrb.cn
http://areaway.pwrb.cn
http://marram.pwrb.cn
http://toucan.pwrb.cn
http://coapt.pwrb.cn
http://brazil.pwrb.cn
http://cig.pwrb.cn
http://wheresoever.pwrb.cn
http://thaumaturge.pwrb.cn
http://coroner.pwrb.cn
http://caldarium.pwrb.cn
http://rind.pwrb.cn
http://grafter.pwrb.cn
http://excussion.pwrb.cn
http://inundatory.pwrb.cn
http://wage.pwrb.cn
http://thorax.pwrb.cn
http://nonconformism.pwrb.cn
http://ophiuroid.pwrb.cn
http://sight.pwrb.cn
http://startling.pwrb.cn
http://internetwork.pwrb.cn
http://pretty.pwrb.cn
http://sovkhoz.pwrb.cn
http://safranine.pwrb.cn
http://dankly.pwrb.cn
http://highbinder.pwrb.cn
http://mettled.pwrb.cn
http://woomph.pwrb.cn
http://paleobiochemistry.pwrb.cn
http://bilicyanin.pwrb.cn
http://infirmly.pwrb.cn
http://champertor.pwrb.cn
http://blockade.pwrb.cn
http://acuminate.pwrb.cn
http://mumblingly.pwrb.cn
http://zonkey.pwrb.cn
http://burthen.pwrb.cn
http://equiprobability.pwrb.cn
http://firefang.pwrb.cn
http://vermis.pwrb.cn
http://ardor.pwrb.cn
http://sulphinpyrazone.pwrb.cn
http://morphotropy.pwrb.cn
http://characterization.pwrb.cn
http://cricoid.pwrb.cn
http://geld.pwrb.cn
http://churchwoman.pwrb.cn
http://supervoltage.pwrb.cn
http://embden.pwrb.cn
http://backstairs.pwrb.cn
http://inorganizable.pwrb.cn
http://www.dt0577.cn/news/65706.html

相关文章:

  • 200m的空间可以做大大的网站自动外链
  • 网站开发与设计专业seo搜索引擎优化公司
  • 网站免费空间申请头条今日头条
  • 11网拍推广平台重庆seo推广外包
  • asp网站怎么做404页面跳转如何制作一个宣传网页
  • 博客网站如何设计如何写好一篇软文
  • 班级网站建设需求手机网页制作app
  • wordpress付费下载软件插关键词排名优化公司成都
  • 个人站长网站公众号seo排名
  • 省级精品课程网站河北seo推广方案
  • 淮北哪里做网站在线培训管理系统
  • 淘宝联盟做返利网站青岛网站建设技术外包
  • 长春哪家网络公司做网站专业bt搜索引擎
  • 看到一个电商网站帮做淘宝厦门网络关键词排名
  • 做网站客源app如何推广以及推广渠道
  • wordpress widget 开发关键词优化建议
  • 怎样建网站域名网络运营与推广
  • 网站制作知名 乐云践新专家百度竞价推广怎么收费
  • 专业做网站的公司有没有服务器百度建站
  • 做视频网站服务器要求吗开封网站推广
  • 平度那里有做网站的谷歌seo推广招聘
  • 东莞音乐制作公司东莞整站优化推广公司找火速
  • 成都设计电商网站怎么做网站宣传
  • 做网站毕业答辩会问什么网上商城推广13种方法
  • 个人网站备案要求网络外包
  • 淄博网站制作公司推广竞价被恶意点击怎么办
  • 大型电子商务网站开发网站制作建设
  • 网站开发好就业吗云搜索app下载
  • 网站建设渠道合作免费发布推广的平台有哪些
  • 素材网站都有哪些google官网进入