Pandastofile¶
flowtask.components.PandasToFile
¶
PandasToFile
¶
Bases: FlowComponent
PandasToFile
Overview
This component exports a pandas DataFrame to a file in CSV, Excel, or JSON format.
.. table:: Properties
:widths: auto
+------------------------+----------+-----------+-----------------------------------------------------------------+
| Name | Required | Summary |
+------------------------+----------+-----------+-----------------------------------------------------------------+
| filename | Yes | The name of the file to save the DataFrame to. |
+------------------------+----------+-----------+-----------------------------------------------------------------+
| directory | No | The directory where the file will be saved. If not specified, |
| | | it will be derived from the filename. |
+------------------------+----------+-----------+-----------------------------------------------------------------+
| mime | No | The MIME type of the file. Supported types are "text/csv", |
| | | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", |
| | | "application/vnd.ms-excel", "application/json". Default is "text/csv". |
+------------------------+----------+-----------+-----------------------------------------------------------------+
| zerofill | No | If True, fills NaN values with "0" in string columns. Default is False. |
+------------------------+----------+-----------+-----------------------------------------------------------------+
| quoting | No | Specifies the quoting behavior for CSV files. Options are "all" (QUOTE_ALL),|
| | | "string" (QUOTE_NONNUMERIC), and None (QUOTE_NONE). Default is None. |
+------------------------+----------+-----------+-----------------------------------------------------------------+
| pd_args | No | Additional arguments for pandas' to_csv, to_excel, or to_json methods. |
| | | Default is an empty dictionary. |
+------------------------+----------+-----------+-----------------------------------------------------------------+
| sep | Yes | Make a separation of the file name with this sign |
+------------------------+----------+-----------+-----------------------------------------------------------------+
Returns
This component returns the filename of the saved file.
Example:
```yaml
PandasToFile:
filename: /home/ubuntu/symbits/bose/files/report/troc_open_tickets_{today}.csv
masks:
'{today}':
- today
- mask: '%Y-%m-%d'
mime: text/csv
quoting: string
pd_args:
sep: ','
```