df-diskcache is a Python library for caching pandas.DataFrame objects to local disk.
Project description
Summary
df-diskcache is a Python library for caching pandas.DataFrame objects to local disk.
Installation
pip install df-diskcache
Features
Supports the following methods:
get: Get a cache entry (pandas.DataFrame) for the key. Returns None if the key is not found.
set: Create a cache entry with an optional time-to-live (TTL) for the key-value pair.
update
touch: Update the last accessed time of a cache entry to extend the TTL.
delete
prune: Delete expired cache entries.
- Dictionary-like operations:
__getitem__
__setitem__
__contains__
__delitem__
Usage
- Sample Code:
import pandas as pd from dfdiskcache import DataFrameDiskCache cache = DataFrameDiskCache() url = "https://raw.githubusercontent.com/pandas-dev/pandas/v2.1.3/pandas/tests/io/data/csv/iris.csv" df = cache.get(url) if df is None: print("cache miss") df = pd.read_csv(url) cache.set(url, df) else: print("cache hit") print(df)
You can also use operations like a dictionary:
- Sample Code:
import pandas as pd from dfdiskcache import DataFrameDiskCache cache = DataFrameDiskCache() url = "https://raw.githubusercontent.com/pandas-dev/pandas/v2.1.3/pandas/tests/io/data/csv/iris.csv" df = cache[url] if df is None: print("cache miss") df = pd.read_csv(url) cache[url] = df else: print("cache hit") print(df)
Dependencies
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
df-diskcache-0.0.1.tar.gz
(8.1 kB
view hashes)
Built Distribution
Close
Hashes for df_diskcache-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8910cb9c24a852dce2adef05762ceaaf73b1bac8d582a9f12ce6a15797409729 |
|
MD5 | e0d22c13aae9762cbb7c6860cdcb8c66 |
|
BLAKE2b-256 | 52ad9f119746ebee2351bdfd5ae5caf4d57e8848ce0f9287405f16c84f78bab7 |