Skip to main content

fabcohort

A small demo library for a fab_cohort about cohort analysis

Installation

pip install fabcohort

Get started

How to do cohort analysis with this lib:

FUNCTION1:

Cohort analysis by segments

Pandas df.head(5) should look like -

user_id date segment count
5fb507360cd5c0 2023-04-01 A,B 1
weg507360cwfw3 2023-03-01 A, 1
6001ef966c13w3 2023-02-01 C,D 1
weg507360cwfw3 2023-04-01 B,D 1
6001ef966c13w3 2023-03-01 A,B 1
from fab_cohort import Cohort

# Instantiate a Cohort object
cohort = Cohort()

# Call the count_cohort_segments method, e.g., MS for month start, W-MON for week start
result = cohort.count_cohort_segments(df, frequency)

# (Optional) if you have multiple segments just parse it
result[['segment1', 'segment2']] = result['segment'].str.split(',', expand=True)
result.drop('segment', axis=1, inplace=True)

FUNCTION3:

Convert the count to percentage

# once the above result is obtained

# Call the count_cohort method
result_pct = cohort.to_pct(result)

# (Optional) if you have multiple segments just parse it
result[['segment1', 'segment2']] = result['segment'].str.split(',', expand=True)
result.drop('segment', axis=1, inplace=True)

Release files for fabcohort 0.3.1

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

Source distribution (sdist)

Source distribution for fabcohort 0.3.1
File Size Uploaded
fabcohort-0.3.1.tar.gz 3.1 kB Details

Built distribution (wheel)

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

Total release size: 6.2 kB

Release files / fabcohort-0.3.1.tar.gz

Download URL fabcohort-0.3.1.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
680ff400a5ef1592d2f141335b0a7d4c85341d6a804ccf2aa19ebc28c39af39b
BLAKE2b-256 checksum
How to use checksums
27d5c3476184cf2cc5b1237aee4805974bf4716e0bbd364ac1302bee457763ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / fabcohort-0.3.1-py3-none-any.whl

Download URL fabcohort-0.3.1-py3-none-any.whl
Size 3.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
034b17dccf613daee1747699f23a3f84e6b33cf7f8f6ade5ab5acd336aa5b916
BLAKE2b-256 checksum
How to use checksums
b9c4668abea15d72e20b9106a0059fcd3f817d278283c83735c39b2391f64ba7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.1.1

2 release files

0.1.0

2 release files

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