Skip to main content

log-count-utils

Introduction & Usage

Suppose we have an action log data df like

user_id timestamp expense
0 2021-02-18 10:00:00 100
0 2021-02-18 10:00:10 10
0 2021-02-18 10:00:21 1
0 2021-02-18 11:00:21 0.1
1 2020-02-18 10:00:10 100
1 2020-02-18 10:00:20 10
1 2020-02-18 10:00:20 1
1 2020-02-18 10:00:29 0

Suppose that you have to compute the following quantity for each row in this dataframe:

  • the number of actions each user has taken within 10 seconds
  • total amount of expenses of a user within 10 seconds

The following naive way is fine for this tiny example but becomes costly (O(N^2)) for large data frame.

from datetime import timedelta
import numpy as np

td = timedelta(seconds=10)

answers = []
for uid, time_point in zip(df.user_id, df.timestamp):
    cnt = np.sum(
        (df.user_id == uid) & (df.timestamp < time_point) & (df.timestamp >= (time_point - td))
    )
    answers.append(cnt)

If df is sorted (by user_id as the primary and timestamp as the secondary key), we can do this blazing fast (O(N)) using log_count_util.

from log_count_util import find_n_records_within_interval

answers = find_n_records_within_interval(
    df.user_id, df.timestamp, df_user_id, df.timestamp, td
)

Metadata

Release files for log-count-util 0.1.0

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

Source distribution (sdist)

Source distribution for log-count-util 0.1.0
File Size Uploaded Provenance Actions
log-count-util-0.1.0.tar.gz 9.2 kB Without provenance Details for log-count-util-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for log-count-util 0.1.0
File Actions
log_count_util-0.1.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details for log_count_util-0.1.0-cp39-cp39-win_amd64.whl
log_count_util-0.1.0-cp39-cp39-win32.whl CPython 3.9 CPython 3.9 Windows x86-32 Details for log_count_util-0.1.0-cp39-cp39-win32.whl
log_count_util-0.1.0-cp39-cp39-manylinux2010_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.12+ x86-64 Details for log_count_util-0.1.0-cp39-cp39-manylinux2010_x86_64.whl
log_count_util-0.1.0-cp39-cp39-manylinux2010_i686.whl CPython 3.9 CPython 3.9 Linux glibc 2.12+ x86-32 Details for log_count_util-0.1.0-cp39-cp39-manylinux2010_i686.whl
log_count_util-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details for log_count_util-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl
log_count_util-0.1.0-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details for log_count_util-0.1.0-cp38-cp38-win_amd64.whl
log_count_util-0.1.0-cp38-cp38-win32.whl CPython 3.8 CPython 3.8 Windows x86-32 Details for log_count_util-0.1.0-cp38-cp38-win32.whl
log_count_util-0.1.0-cp38-cp38-manylinux2010_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.12+ x86-64 Details for log_count_util-0.1.0-cp38-cp38-manylinux2010_x86_64.whl
log_count_util-0.1.0-cp38-cp38-manylinux2010_i686.whl CPython 3.8 CPython 3.8 Linux glibc 2.12+ x86-32 Details for log_count_util-0.1.0-cp38-cp38-manylinux2010_i686.whl
log_count_util-0.1.0-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details for log_count_util-0.1.0-cp38-cp38-macosx_10_9_x86_64.whl
log_count_util-0.1.0-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details for log_count_util-0.1.0-cp37-cp37m-win_amd64.whl
log_count_util-0.1.0-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details for log_count_util-0.1.0-cp37-cp37m-win32.whl
log_count_util-0.1.0-cp37-cp37m-manylinux2010_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64 Details for log_count_util-0.1.0-cp37-cp37m-manylinux2010_x86_64.whl
log_count_util-0.1.0-cp37-cp37m-manylinux2010_i686.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-32 Details for log_count_util-0.1.0-cp37-cp37m-manylinux2010_i686.whl
log_count_util-0.1.0-cp37-cp37m-macosx_10_9_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 Details for log_count_util-0.1.0-cp37-cp37m-macosx_10_9_x86_64.whl

Total release size: 5.4 MB

Release files / log-count-util-0.1.0.tar.gz

Download URL log-count-util-0.1.0.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
03351abb25e7fa5b817b41fcd93b063b3e2f7d47a51bf6699bd3c4d771be3aef
BLAKE2b-256 checksum
How to use checksums
e333ab84b6fb465395114be9be88e4257be96564862439dcb9ccf1461cf8f16f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / log_count_util-0.1.0-cp39-cp39-win_amd64.whl

Download URL log_count_util-0.1.0-cp39-cp39-win_amd64.whl
Size 61.1 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
2417d491fd4eb41716aa1f121940157157a13891d25cdc79bba74f2b30928b73
BLAKE2b-256 checksum
How to use checksums
e2325b54104aa929676027cd4febfb7783cae61de5e82a89d9f34e3f671377a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / log_count_util-0.1.0-cp39-cp39-win32.whl

Download URL log_count_util-0.1.0-cp39-cp39-win32.whl
Size 54.0 kB
Tags CPython 3.9 Windows x86-32
SHA-256 checksum
How to use checksums
01df9b385f8433eebea33cc039233e020f93f0a79bf353e729b7ceaa0218c4dd
BLAKE2b-256 checksum
How to use checksums
72bd864b0f06306b5f1782ea455b37d116e506542f440ea3751754c508e9d3a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / log_count_util-0.1.0-cp39-cp39-manylinux2010_x86_64.whl

Download URL log_count_util-0.1.0-cp39-cp39-manylinux2010_x86_64.whl
Size 809.0 kB
Tags CPython 3.9 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
a0416f117d61942f8de2ead92be5f70c0392349c05e02a3e3b00cc1c33c012bf
BLAKE2b-256 checksum
How to use checksums
ebb7617ba53974a5ecde1acd14a9f63990a67973383a6e4c040c2edc4d5c0e83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / log_count_util-0.1.0-cp39-cp39-manylinux2010_i686.whl

Download URL log_count_util-0.1.0-cp39-cp39-manylinux2010_i686.whl
Size 806.5 kB
Tags CPython 3.9 Linux glibc 2.12+ x86-32
SHA-256 checksum
How to use checksums
89f747fa4d7ee4b30b3e646f474040ab0a44f4258d711682950abd4f4a3254b7
BLAKE2b-256 checksum
How to use checksums
dcf1d39e4bb8f9726ba2882fd286bb5363826ae6549b84f1f308379ce3cdab02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / log_count_util-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl

Download URL log_count_util-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl
Size 73.6 kB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
47b2903e3180240b7eed5983f0ff5ca0e23c9552325c71aff78e10ca288095cd
BLAKE2b-256 checksum
How to use checksums
930df2c69e8cd5141afb3f135e861be22e25bde1297d240a34a5c2a2595aa798
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / log_count_util-0.1.0-cp38-cp38-win_amd64.whl

Download URL log_count_util-0.1.0-cp38-cp38-win_amd64.whl
Size 61.6 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
4bcc2a9164ba95288e2601c4e719acfcc6236bf1cbc324882e9ef48ed0236899
BLAKE2b-256 checksum
How to use checksums
2d38f867a36c7387c5be341614297e8a08ba05766676587cb168b1ef55b846cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / log_count_util-0.1.0-cp38-cp38-win32.whl

Download URL log_count_util-0.1.0-cp38-cp38-win32.whl
Size 54.0 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
f1ce2fb58421f2e6042293f5a8193dd512546c4963c68bd92000b6e0ba6280aa
BLAKE2b-256 checksum
How to use checksums
f45614710349adc075e77d20130eb30dfb704ca05c37a41254aea1d40250a504
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / log_count_util-0.1.0-cp38-cp38-manylinux2010_x86_64.whl

Download URL log_count_util-0.1.0-cp38-cp38-manylinux2010_x86_64.whl
Size 808.9 kB
Tags CPython 3.8 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
83afca16ac4f03129a84204af3c0a82ae7ba10d67f456e1cd45c7708b68cb015
BLAKE2b-256 checksum
How to use checksums
69ac35bc17d798001908ad322a65ec135ee321946b01022d2c93997a48dbb518
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / log_count_util-0.1.0-cp38-cp38-manylinux2010_i686.whl

Download URL log_count_util-0.1.0-cp38-cp38-manylinux2010_i686.whl
Size 805.0 kB
Tags CPython 3.8 Linux glibc 2.12+ x86-32
SHA-256 checksum
How to use checksums
dc02e0fc1c53f7375294487a4b8abfad43b0d88385de08420b56f36ccaf1e083
BLAKE2b-256 checksum
How to use checksums
af0ce9be42f2aea7c6ec204daf6958848007433d37638e714999c0e1f4800362
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / log_count_util-0.1.0-cp38-cp38-macosx_10_9_x86_64.whl

Download URL log_count_util-0.1.0-cp38-cp38-macosx_10_9_x86_64.whl
Size 73.4 kB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
c71004f01ef2f51e980041d2726dfba4bac21db0884cf8897a882fd4e5f8a488
BLAKE2b-256 checksum
How to use checksums
f58332c078c7c069606513782d5c0d387e01e429174447c969cdc430a5cc66a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / log_count_util-0.1.0-cp37-cp37m-win_amd64.whl

Download URL log_count_util-0.1.0-cp37-cp37m-win_amd64.whl
Size 62.1 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
f41a3e260551607560f4e7e67b1e40aeeb90b720c51b4631429ab4ba7af6d68d
BLAKE2b-256 checksum
How to use checksums
cf1847ebf4d5aa83da69dcd5fc11809029ed0c2b4dade55edc3d1140ceb5dfc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / log_count_util-0.1.0-cp37-cp37m-win32.whl

Download URL log_count_util-0.1.0-cp37-cp37m-win32.whl
Size 54.6 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
389789c0bb3a0bf8353b95b0df07e8be57793aad5c39df097c87a0fb4a5ab50f
BLAKE2b-256 checksum
How to use checksums
deb69a7b69de95b8293554eab653b9977518192b87f1fd6357aa56ed6dfec19b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / log_count_util-0.1.0-cp37-cp37m-manylinux2010_x86_64.whl

Download URL log_count_util-0.1.0-cp37-cp37m-manylinux2010_x86_64.whl
Size 821.5 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
38bc9013bde76782fc553a2a7f66ce7a5416c9d31f6509b490cd769f956d82bf
BLAKE2b-256 checksum
How to use checksums
b2b07c824deda82fb0ef077b370dc0f2db1c9ecf05681e3533f50632d34a00d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / log_count_util-0.1.0-cp37-cp37m-manylinux2010_i686.whl

Download URL log_count_util-0.1.0-cp37-cp37m-manylinux2010_i686.whl
Size 812.1 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-32
SHA-256 checksum
How to use checksums
30cdcfba566f18047a4c0506cefc5809c72a2cfed11023452a0339da38a50170
BLAKE2b-256 checksum
How to use checksums
882fc3b4d3facc5c353e24c41dd46287e0327e89779b8d576abd8d43f3f4beef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / log_count_util-0.1.0-cp37-cp37m-macosx_10_9_x86_64.whl

Download URL log_count_util-0.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
Size 72.9 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
fee0c67fb5f16e31f35ad2e624d5a7bb7fbe8c0e97c1856a14ceb271225199b0
BLAKE2b-256 checksum
How to use checksums
c9a2eb52466905e52b3a2c655dcebd62c8d40e213741883e9d72c3cca043b27b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Security for log-count-util 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

16 release files No provenance

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