Skip to main content

Add user-defined methods to Python classes.

Project description

f2m: Turn user-defined functions into methods

Pandas DataFrame example

import pandas as pd
from f2m import f2m

# create a new class that inherits from pd.DataFrame
# and includes methods defined in a 'helper.py' file
F2mFrame = f2m(cls=pd.DataFrame, src='helper')

# instantiate the new class
df = F2mFrame(data=pd.read_csv('risk_factors_cervical_cancer.csv'))

# test methods added from helper file
df.say_hi()
df.say_moo()

# test method from parent class
df.head(n=1)

# confirm that df is an instance of pd.DataFrame and PydyFrame
isinstance(df, (pd.DataFrame, F2mFrame))

# confirm that F2mFrame is a subclass of pd.DataFrame
issubclass(F2mFrame, pd.DataFrame)

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

f2m-0.0.1.tar.gz (1.6 kB view details)

Uploaded Source

Built Distribution

f2m-0.0.1-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

File details

Details for the file f2m-0.0.1.tar.gz.

File metadata

  • Download URL: f2m-0.0.1.tar.gz
  • Upload date:
  • Size: 1.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5

File hashes

Hashes for f2m-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9bcff066cfd3c56b3750f40564b64b9b1cc773eca3e56653225d1495b7cba319
MD5 ddd2471f7c99eb1f0ae875b7bbc29612
BLAKE2b-256 7a893fe7e79e62d7fe74f4ac117530c25ee69a0c92f773141a1a2233adbcf26f

See more details on using hashes here.

File details

Details for the file f2m-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: f2m-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5

File hashes

Hashes for f2m-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 75e9e081810638a398ea3dd89ea3631276cc3f1428776543eceec00adbbc1885
MD5 9a6f7bbb71ae22c35c5452bf787b1c5a
BLAKE2b-256 9adb3e2fbf72b919b46aeaf30070ed1528a85b8f228f07396fd1d387d128e680

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