Skip to main content

arraytool

介绍

基于numpy的Series及DataFrame数据结构。

arraytool包中对应于Series及DataFrame的数据类分别为ArraySeries及ArrayFrame,两者同Series及DataFrame之间可方便地进行转换。

安装

pip install arraytool

引入

import arraytool
from arraytool import ArraySeries, ArrayFrame

ArraySeries

构造

>>> s1 = ArraySeries(['a','bb','ccc'])
>>> s1
0      a
1     bb
2    ccc
dtype: object

取值

>>> s1[2]
'ccc'
>>> s1[:2]
0     a
1    bb
dtype: object

使用索引

>>> s2 = ArraySeries([2,3,4,5],list('aabc'))
>>> s2.iloc[:2]
a    2
a    3
dtype: object
>>> s2.loc['a']
a    2
a    3
dtype: object
>>> s2.loc['b']
4
>>> s2.loc[list('ab')]
a    2
a    3
b    4
dtype: object

ArrayFrame

构造

>>> af = ArrayFrame()
>>> af['A'] = list('abcd')
>>> af['B'] = range(4)
>>> af['C'] = [True,True,False,False]
>>> af
   A  B      C
0  a  0   True
1  b  1   True
2  c  2  False
3  d  3  False

取值

>>> af[list('BC')]
   B      C
0  0   True
1  1   True
2  2  False
3  3  False

使用索引

iloc索引

>>> af.iloc[0,0]
'a'
>>> af.iloc[0]
   A  B     C
0  a  0  True

loc索引

>>> af.set_index(index_cols='A')
>>> af
   A  B      C
A             
a  a  0   True
b  b  1   True
c  c  2  False
d  d  3  False
>>> af.loc['a','C']
True
>>> af.loc[list('bd'),list('AC')]
   A      C
A          
b  b   True
d  d  False

ix索引

类R语言data.frame的索引语法,使用pandas弃用的ix索引器。

>>> af.ix[2,'B']
2
>>> af.ix[:2,list('AB')]
   A  B
A      
a  a  0
b  b  1

Metadata

Release files for arraytool 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for arraytool 0.1.5
File Size Uploaded
arraytool-0.1.5.tar.gz 47.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for arraytool 0.1.5
File Interpreter ABI Platform
arraytool-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 96.3 kB

Release files / arraytool-0.1.5.tar.gz

Download URL arraytool-0.1.5.tar.gz
Size 47.6 kB
Tags Source
SHA-256 checksum
How to use checksums
54e8314faca2d138167d0660e0ebbb523de2f1286c44702b905c5b4829ca935f
BLAKE2b-256 checksum
How to use checksums
b1ce0f28cdef7b0bbb695f2ba0c1ce987b37cd02cc23f3c0d3ec02548914b306
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.7

Release files / arraytool-0.1.5-py3-none-any.whl

Download URL arraytool-0.1.5-py3-none-any.whl
Size 48.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18f939791f9f8f2188181eff41f5099c4587a30f63f88cb7506dd534ca77dc0c
BLAKE2b-256 checksum
How to use checksums
1b70c2801da17fb6d1b271697c9c7f4118f376b7a7b4f533f105a6832cb7e210
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.7

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

3 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page