df-diskcache


Namedf-diskcache JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/thombashi/df-diskcache
Summarydf-diskcache is a Python library for caching pandas.DataFrame objects to local disk.
upload_time2023-11-26 23:51:28
maintainer
docs_urlNone
authorTsuyoshi Hombashi
requires_python>=3.7
licenseMIT License
keywords cache disk dataframe library pandas
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. contents:: **df-diskcache**
   :backlinks: top
   :depth: 2


Summary
============================================

``df-diskcache`` is a Python library for caching ``pandas.DataFrame`` objects to local disk.

.. image:: https://badge.fury.io/py/df-diskcache.svg
    :target: https://badge.fury.io/py/df-diskcache
    :alt: PyPI package version

.. image:: https://img.shields.io/pypi/pyversions/df-diskcache.svg
    :target: https://pypi.org/project/df-diskcache
    :alt: Supported Python versions

.. image:: https://github.com/thombashi/df-diskcache/actions/workflows/ci.yml/badge.svg
    :target: https://github.com/thombashi/df-diskcache/actions/workflows/ci.yml
    :alt: CI status of Linux/macOS/Windows

.. image:: https://coveralls.io/repos/github/thombashi/df-diskcache/badge.svg?branch=master
    :target: https://coveralls.io/github/thombashi/df-diskcache?branch=master
    :alt: Test coverage: coveralls

.. image:: https://github.com/thombashi/df-diskcache/actions/workflows/github-code-scanning/codeql/badge.svg
    :target: https://github.com/thombashi/df-diskcache/actions/workflows/github-code-scanning/codeql
    :alt: CodeQL


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:
    .. code-block:: python

        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:
    .. code-block:: python

        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)


Set TTL for cache entries
--------------------------------------------

:Sample Code:
    .. code-block:: python

        import pandas as pd
        from dfdiskcache import DataFrameDiskCache

        DataFrameDiskCache.DEFAULT_TTL = 10  # you can override the default TTL (default: 3600 seconds)

        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:
            df = pd.read_csv(url)
            cache.set(url, df, ttl=60)  # you can set a TTL for the key-value pair

        print(df)


Dependencies
============================================
- Python 3.7+
- `Python package dependencies (automatically installed) <https://github.com/thombashi/df-diskcache/network/dependencies>`__

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/thombashi/df-diskcache",
    "name": "df-diskcache",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "cache,disk,dataframe,library,pandas",
    "author": "Tsuyoshi Hombashi",
    "author_email": "tsuyoshi.hombashi@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b5/c1/a951201dbe93782f8c3b84a2b303240f05b4d6af3c6c3636d3aa9d8b183e/df-diskcache-0.0.2.tar.gz",
    "platform": null,
    "description": ".. contents:: **df-diskcache**\n   :backlinks: top\n   :depth: 2\n\n\nSummary\n============================================\n\n``df-diskcache`` is a Python library for caching ``pandas.DataFrame`` objects to local disk.\n\n.. image:: https://badge.fury.io/py/df-diskcache.svg\n    :target: https://badge.fury.io/py/df-diskcache\n    :alt: PyPI package version\n\n.. image:: https://img.shields.io/pypi/pyversions/df-diskcache.svg\n    :target: https://pypi.org/project/df-diskcache\n    :alt: Supported Python versions\n\n.. image:: https://github.com/thombashi/df-diskcache/actions/workflows/ci.yml/badge.svg\n    :target: https://github.com/thombashi/df-diskcache/actions/workflows/ci.yml\n    :alt: CI status of Linux/macOS/Windows\n\n.. image:: https://coveralls.io/repos/github/thombashi/df-diskcache/badge.svg?branch=master\n    :target: https://coveralls.io/github/thombashi/df-diskcache?branch=master\n    :alt: Test coverage: coveralls\n\n.. image:: https://github.com/thombashi/df-diskcache/actions/workflows/github-code-scanning/codeql/badge.svg\n    :target: https://github.com/thombashi/df-diskcache/actions/workflows/github-code-scanning/codeql\n    :alt: CodeQL\n\n\nInstallation\n============================================\n::\n\n    pip install df-diskcache\n\n\nFeatures\n============================================\n\nSupports the following methods:\n\n- ``get``: Get a cache entry (``pandas.DataFrame``) for the key. Returns ``None`` if the key is not found.\n- ``set``: Create a cache entry with an optional time-to-live (TTL) for the key-value pair.\n- ``update``\n- ``touch``: Update the last accessed time of a cache entry to extend the TTL.\n- ``delete``\n- ``prune``: Delete expired cache entries.\n- Dictionary-like operations:\n    - ``__getitem__``\n    - ``__setitem__``\n    - ``__contains__``\n    - ``__delitem__``\n\n\nUsage\n============================================\n\n:Sample Code:\n    .. code-block:: python\n\n        import pandas as pd\n        from dfdiskcache import DataFrameDiskCache\n\n        cache = DataFrameDiskCache()\n        url = \"https://raw.githubusercontent.com/pandas-dev/pandas/v2.1.3/pandas/tests/io/data/csv/iris.csv\"\n\n        df = cache.get(url)\n        if df is None:\n            print(\"cache miss\")\n            df = pd.read_csv(url)\n            cache.set(url, df)\n        else:\n            print(\"cache hit\")\n\n        print(df)\n\nYou can also use operations like a dictionary:\n\n:Sample Code:\n    .. code-block:: python\n\n        import pandas as pd\n        from dfdiskcache import DataFrameDiskCache\n\n        cache = DataFrameDiskCache()\n        url = \"https://raw.githubusercontent.com/pandas-dev/pandas/v2.1.3/pandas/tests/io/data/csv/iris.csv\"\n\n        df = cache[url]\n        if df is None:\n            print(\"cache miss\")\n            df = pd.read_csv(url)\n            cache[url] = df\n        else:\n            print(\"cache hit\")\n\n        print(df)\n\n\nSet TTL for cache entries\n--------------------------------------------\n\n:Sample Code:\n    .. code-block:: python\n\n        import pandas as pd\n        from dfdiskcache import DataFrameDiskCache\n\n        DataFrameDiskCache.DEFAULT_TTL = 10  # you can override the default TTL (default: 3600 seconds)\n\n        cache = DataFrameDiskCache()\n        url = \"https://raw.githubusercontent.com/pandas-dev/pandas/v2.1.3/pandas/tests/io/data/csv/iris.csv\"\n\n        df = cache.get(url)\n        if df is None:\n            df = pd.read_csv(url)\n            cache.set(url, df, ttl=60)  # you can set a TTL for the key-value pair\n\n        print(df)\n\n\nDependencies\n============================================\n- Python 3.7+\n- `Python package dependencies (automatically installed) <https://github.com/thombashi/df-diskcache/network/dependencies>`__\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "df-diskcache is a Python library for caching pandas.DataFrame objects to local disk.",
    "version": "0.0.2",
    "project_urls": {
        "Changlog": "https://github.com/thombashi/df-diskcache/releases",
        "Homepage": "https://github.com/thombashi/df-diskcache",
        "Source": "https://github.com/thombashi/df-diskcache",
        "Tracker": "https://github.com/thombashi/df-diskcache/issues"
    },
    "split_keywords": [
        "cache",
        "disk",
        "dataframe",
        "library",
        "pandas"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5a0a471991d408b270b052b2b0aaf5734856cc65ff4177db57c8b32800b6634d",
                "md5": "7584273beae391cc4456ae12d55fedc1",
                "sha256": "dcb6c9b1ea31d18aa51e26db23468cb1a5f97b37943172951812352138a106b8"
            },
            "downloads": -1,
            "filename": "df_diskcache-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7584273beae391cc4456ae12d55fedc1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6489,
            "upload_time": "2023-11-26T23:51:26",
            "upload_time_iso_8601": "2023-11-26T23:51:26.821002Z",
            "url": "https://files.pythonhosted.org/packages/5a/0a/471991d408b270b052b2b0aaf5734856cc65ff4177db57c8b32800b6634d/df_diskcache-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b5c1a951201dbe93782f8c3b84a2b303240f05b4d6af3c6c3636d3aa9d8b183e",
                "md5": "2b9e049211e1df05b3f04d3703b81fb7",
                "sha256": "d050bf3f4eb4f1f141a2f0ac5fc160fbeb880098c13e411d5357ea48d2d36f0f"
            },
            "downloads": -1,
            "filename": "df-diskcache-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "2b9e049211e1df05b3f04d3703b81fb7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 8290,
            "upload_time": "2023-11-26T23:51:28",
            "upload_time_iso_8601": "2023-11-26T23:51:28.756630Z",
            "url": "https://files.pythonhosted.org/packages/b5/c1/a951201dbe93782f8c3b84a2b303240f05b4d6af3c6c3636d3aa9d8b183e/df-diskcache-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-26 23:51:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "thombashi",
    "github_project": "df-diskcache",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "df-diskcache"
}
        
Elapsed time: 0.14789s