load_df
- load_df(key, *subkeys, name, read_csv_kwargs=None)[source]
Open a pre-existing CSV as a dataframe with
pandas
.- Parameters:
key (
str
) – The module namesubkeys (
str
) – A sequence of additional strings to join. If none are given, returns the directory for this module.name (
str
) – 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 (
Optional
[Mapping
[str
,Any
]]) – Keyword arguments to pass through topandas.read_csv()
.
- Return type:
- 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')