DataFrame Exporter
Bases: ABC
flowchart TD
metaframe.src.dataframe.exporter.base.DataFrameExporter[DataFrameExporter]
click metaframe.src.dataframe.exporter.base.DataFrameExporter href "" "metaframe.src.dataframe.exporter.base.DataFrameExporter"
Source code in metaframe/src/dataframe/exporter/base.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
__init__(df, *args, **kwargs)
Initialize the exporter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
The DataFrame to export. |
required |
*args
|
Arguments used to construct the exporter-specific options dataclass. Supported keys depend on the concrete exporter. |
()
|
|
**kwargs
|
Arguments used to construct the exporter-specific options dataclass. Supported keys depend on the concrete exporter. |
()
|
Notes
The provided options are validated and normalized by prepare_opts
before export. The original DataFrame is never modified in place.
Source code in metaframe/src/dataframe/exporter/base.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
export()
abstractmethod
Execute the export process.
This method must be implemented by subclasses to serialize the prepared DataFrame into the target format.
Source code in metaframe/src/dataframe/exporter/base.py
39 40 41 42 43 44 45 46 47 | |
set_mfr_shape()
Sets the expected MetaFrameRow shape in the export.
MetaFrameRow shape for non-tables, DataFrame number of rows & 1 (if header+index) or 0 fr tables
Source code in metaframe/src/dataframe/exporter/base.py
49 50 51 52 53 54 55 56 57 58 | |
set_mfc_shape()
Sets the expected MetaFrameCol shape in the export.
MetaFrameCol shape for non-tables, DataFrame number of rows & 1 (if header+index) or 0 fr tables
Source code in metaframe/src/dataframe/exporter/base.py
60 61 62 63 64 65 66 67 68 69 | |
prepare_opts(*args, **kwargs)
Normalize and infer export options.
This method fills in missing option values using sensible defaults derived from the DataFrame structure (table vs non-table).
Rules
extensivedefaults to True for non-tables, False for tablesindexdefaults to False for tables, True for non-tables
Notes
This method mutates self.opts in place and is intended to be called
internally by export. Users should not call it directly.
Source code in metaframe/src/dataframe/exporter/base.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
prepare_data(df)
Prepare a copy of the DataFrame for serialization.
The returned DataFrame is transformed to ensure it can be written and later reconstructed correctly by readers. Transformations may include:
- resetting the index/columns
- normalizing headers
- converting indices/columns to MultiIndex form
- adding MetaFrames rows unique identifiers
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
|
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
A modified copy of the original DataFrame ready for export. |
Notes
The original DataFrame is not modified.
Source code in metaframe/src/dataframe/exporter/base.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |