load_df

load_df(key: str, *subkeys: str, name: str, read_csv_kwargs: Mapping[str, Any] | None = None) pd.DataFrame[source]

Open a pre-existing CSV as a dataframe with pandas.

Parameters:
  • key – The module name

  • subkeys – A sequence of additional strings to join. If none are given, returns the directory for this module.

  • name – Overrides the name of the file at the end of the URL, if given. Also useful for URLs that don’t have proper filenames with extensions.

  • read_csv_kwargs – Keyword arguments to pass through to pandas.read_csv().

Returns:

A pandas DataFrame

Example usage:

>>> import pystow
>>> import pandas as pd
>>> url = "https://raw.githubusercontent.com/pykeen/pykeen/master/src/pykeen/datasets/nations/test.txt"
>>> pystow.ensure_csv("pykeen", "datasets", "nations", url=url)
>>> df: pd.DataFrame = pystow.load_df("pykeen", "datasets", "nations", name="test.txt")