civis.io.dataframe_to_file
- civis.io.dataframe_to_file(df: pd.DataFrame | pl.DataFrame, name: str = 'data.csv', expires_at: str | None = 'DEFAULT', description: str | None = None, client: APIClient | None = None, **to_csv_kws)[source]
Store a dataframe as a CSV in Civis Platform.
- Parameters:
- df
DataFrame|polars.DataFrame The dataframe to upload.
- namestr, optional
The name of the Civis File
- expires_atstr, optional
The date and time the file will expire. If not specified, the file will expire in 30 days. To specify a date and time, format it by the ISO 8601 standard (e.g.,
"2020-12-31","2020-12-31T23:03:40Z"), or equivalently, the returned value of theisoformat()method from adatetime.dateordatetime.datetimeobject. To keep a file indefinitely, specifyNone.- descriptionstr, optional
Description (max length: 512 characters) of the file object.
- client
civis.APIClient, optional If not provided, an
civis.APIClientobject will be created from theCIVIS_API_KEY.- **to_csv_kws
Additional keyword parameters will be passed directly to
to_csv()orpolars.DataFrame.write_csv().
- df
- Returns:
- file_idint
The integer ID of the new Civis File object
- Raises:
- ValueError
If
descriptionis provided and it’s longer than 512 characters.
See also
file_to_civis()to_csv()polars.DataFrame.write_csv()