Skip to main content

对pandas进行配置文件操作,用yml文件对pandas进行操作,无须写一行代码即可分析数据。

Project description

pyaxe-pandas

对pandas进行配置文件操作,用yml文件对pandas进行操作,无须写一行代码即可分析数据。

安装

pip install pyaxe-pandas

执行

from pyaxe_pandas import YamlPandas
import pandas as pd
df=pd.DataFrame()

yp = YamlPandas(df=df, yml='yaml配置文件地址')
result = yp.resolve_config(yp.read_yaml())
for data in result:
    print(data)

语法文档

语法文档

生成初始化数据

import pandas as pd
import random

random.seed(100)
df=pd.DataFrame({'age':[random.randint(10,100) for i in range(2000)],'sex':['男' if random.randint(10,100)%2==0 else '女' for i in range(2000)]})
'''
age	sex
0	28	女
1	68	女
2	68	女
3	32	女
4	100	男
...	...	...
1995	14	女
1996	33	女
1997	23	男
1998	92	女
1999	76	女
2000 rows × 2 columns
'''

一系列过滤操作

# df
#   age	sex
#0	28	女
#1	68	女
#2	68	女
#3	32	女
#4	100	男
#...	...	...
#1995	14	女
#1996	33	女
#1997	23	男
#1998	92	女
#1999	76	女
#2000 rows × 2 columns

# 1、 大于50岁的人
version: 1.1.0
operations:
  - operation:
      name: query
      exe: age > 60 and sex =="男"
---

# 2、 大于60岁的男人
version: 1.1.0
operations:
  - operation:
      name: query
      exe: age > 60 and sex =="男"
---

# 3、 大于30岁的男人或者小于70岁的女人
version: 1.1.0
operations:
  - operation:
      name: query
      exe: (age > 60 and sex =="男") or (age < 70 and sex=="女")
---

# 4、 大于平均年龄的女人
version: 1.1.0
operations:
  - operation:
      name: query
      exe: age > age.mean() and sex =="女"

条件过滤

version: 1.1.0
operations:
  - operation:
      name: query
      switch:
        - regex: 大于50岁 # 大于50岁的人
          arg: text # 匹配的参数
          exe: age > 50
          stop: true

        - regex: 大于60岁.+男 # 大于60岁的男人
          arg: text
          exe: age > 60 and sex =="男"
          stop: true

        - regex: .+30岁的男人或者小于70岁的女人 # 大于30岁的男人或者小于70岁的女人
          arg: text
          exe: (age > 60 and sex =="男") or (age < 70 and sex=="女")
          stop: true

        - regex: 平均年龄.+女人 # 大于平均年龄的女人
          arg: text
          exe: age > age.mean() and sex =="女"
          stop: true

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pyaxe_pandas-2020.8.18-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file pyaxe_pandas-2020.8.18-py3-none-any.whl.

File metadata

  • Download URL: pyaxe_pandas-2020.8.18-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for pyaxe_pandas-2020.8.18-py3-none-any.whl
Algorithm Hash digest
SHA256 fb16890a56095ccc125be132de9534c75ae4ede889837e0db56bb28969016dd4
MD5 356299e74f3086ea906549dff4b0ce4a
BLAKE2b-256 8d5c67a1d0f1d4fb6b9b1699cdacbc098a407065a795920f0f7ec16ac73ebbf4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page