civis.io.file_to_dataframe
- civis.io.file_to_dataframe(file_id: int, return_as: str = 'pandas', compression: str = 'infer', client: APIClient | None = None, **read_kwargs) pd.DataFrame | pl.DataFrame[source]
Load a dataframe from a CSV stored in a Civis File.
The dataframe will be read directly from Civis without copying the CSV to a local file on disk.
- Parameters:
- file_idint
ID of a Civis File which contains a CSV
- return_asstr, {“pandas”, “polars”}
Return a
pandas.DataFrameinstance if"pandas"is provided, or apolars.DataFrameinstance for"polars". Default:"pandas".- compressionstr, optional
(Only active if
return_asis"pandas".) If “infer”, set thecompressionargument ofpandas.read_csv()based on the file extension of the name of the Civis File. Otherwise pass this argument topandas.read_csv().- client
civis.APIClient, optional If not provided, an
civis.APIClientobject will be created from theCIVIS_API_KEY.- **read_kwargs
Additional arguments will be passed directly to
read_csv()orpolars.read_csv().
- Returns:
DataFrameorpolars.DataFrame
- Raises:
- ImportError
If
return_asis"pandas"and pandas is not installed. Ifreturn_asis"polars"and polars is not installed.
See also