Skip to main content

A lightweight single file DataFrame implementation that works on older Python distrubtions such as Jython.

Project description

A lightweight single file DataFrame implementation that works on older Python distrubtions such as Jython.

I use it with Java data tools such as Streamsets.

Feel free to fork, add tests and features and make a pull request.

Install

$ pip install mframe

or copy mframe.py to your project folder.

Usage

It’s goal is to be familar to pandas users without promising 100% compatability. My workflow usually involves writing the code in a Jupyter notebook using Python 3 and then testing it with Jython before deploying it to Streamsets.

>>> from mframe import DataFrame
>>> data = {'col_1': [3, 2, 1, 0], 'col_2': ['a', 'b', 'c', 'd']}
>>> df = DataFrame(data)
>>> df
{'col_1': [3, 2, 1, 0], 'col_2': ['a', 'b', 'c', 'd']}
>>> df.pd #  the pd alias returns a pandas dataframe, useful for printing in Jupyter when developing
     col_1 col_2
0      3     a
1      2     b
2      1     c
3      0     d
>>> df['col_1'] # Subscript access
[3, 2, 1, 0]
>>> df.col_1 # Attribute access
[3, 2, 1, 0]
>>> df[df.col_1 > 1] # filtering works
     col_1 col_2
0      3     a
1      2     b
>>> df[(df.col_1 > 1) & (df.col_2 == 'a')]
     col_1 col_2
0      3     a
>>> df['col_1'] = df.col_1.apply(str) # Apply is available
>>> df.col_1
['3', '2', '1', '0']
>>> list(df.iterrows()) # returns a generator of dictionaries
[{'col_1': '3', 'col_2': 'a'}, {'col_1': '2', 'col_2': 'b'}, {'col_1': '1', 'col_2': 'c'}, {'col_1': '0', 'col_2': 'd'}]

Tested on

  • Python 3.7

  • Jython 2.7

Project details


Download files

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

Source Distribution

mframe-0.2.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mframe-0.2.2-py2.py3-none-any.whl (3.8 kB view details)

Uploaded Python 2Python 3

mframe-0.2.2-py2.7.egg (12.3 kB view details)

Uploaded Egg

File details

Details for the file mframe-0.2.2.tar.gz.

File metadata

  • Download URL: mframe-0.2.2.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for mframe-0.2.2.tar.gz
Algorithm Hash digest
SHA256 81b23ab0e58f6017a8dfbe461d7b4fae090965ad3b66bdaa1e5d2c53fbaed9b2
MD5 0617ce5f4dead0ee5ee31acec7141855
BLAKE2b-256 88c78652d2d0239c5e627b98514127a4f7d07a5928b0869c587ebab4e1826296

See more details on using hashes here.

File details

Details for the file mframe-0.2.2-py2.py3-none-any.whl.

File metadata

  • Download URL: mframe-0.2.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for mframe-0.2.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 504b9d9da7c0eac4ab41a1c36463a453b7e93d9ecf99dc2035df6d24402a083d
MD5 210812974ad66bfeca507548f2d6afbd
BLAKE2b-256 712c5e34e38e6ac3d82c4260b127e2b6c87a804119d857ea7e09a26ca77f431d

See more details on using hashes here.

File details

Details for the file mframe-0.2.2-py2.7.egg.

File metadata

  • Download URL: mframe-0.2.2-py2.7.egg
  • Upload date:
  • Size: 12.3 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for mframe-0.2.2-py2.7.egg
Algorithm Hash digest
SHA256 49e59db7be14a08e4cff7ebc80aad2856bdca10f7da7d766302cff6ad1ed3217
MD5 6a0da47ed657f519d2e62981c7d4a400
BLAKE2b-256 5565864a59ac5ce91cb18cf49579a0d7a16ae17125f73b4de4522c6f2b724bdb

See more details on using hashes here.

Supported by

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