convenience
convenience ¶
generate_schema_from_dataframe ¶
generate_schema_from_dataframe(
df: DataFrame,
upsert_key: str | None = None,
column_types: dict[str, str] | None = None,
) -> dict
Generate a Domo schema dict from a pandas DataFrame.
Maps pandas dtypes to Domo schema column types: object/bool -> STRING, integer -> LONG, float -> DOUBLE, datetime -> DATETIME.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
pandas DataFrame to analyze |
required |
upsert_key
|
str | None
|
Column name to mark as the identity/upsert column |
None
|
column_types
|
dict[str, str] | None
|
Override mapping {column_name: "STRING"|"LONG"|"DOUBLE"|"DATE"|"DATETIME"} |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
{"columns": [{"name": "...", "type": "...", "upsertKey": bool}, ...]} |
Source code in src/crew_dcs/routes/dataset/convenience.py
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 | |
upload_dataframe
async
¶
upload_dataframe(
auth: DomoAuth,
dataset_name: str,
df: DataFrame,
*,
schema: dict | None = None,
upsert_key: str | None = None,
column_types: dict[str, str] | None = None,
update_method: str = "REPLACE",
is_index: bool = True,
is_create_if_not_exists: bool = True,
context: RouteContext | None = None,
**context_kwargs
) -> ResponseGetData
Upload a DataFrame to Domo in one call.
If the dataset doesn't exist, creates it with an auto-detected schema. If it does exist, amends the schema for any new DataFrame columns before uploading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth
|
DomoAuth
|
Authentication object for API requests |
required |
dataset_name
|
str
|
Name of the dataset to find or create |
required |
df
|
DataFrame
|
DataFrame to upload |
required |
schema
|
dict | None
|
Explicit schema override used when creating a new dataset |
None
|
upsert_key
|
str | None
|
Column name to mark as the identity/upsert column |
None
|
column_types
|
dict[str, str] | None
|
Override auto-detected types for specific columns |
None
|
update_method
|
str
|
"REPLACE" or "APPEND" |
'REPLACE'
|
is_index
|
bool
|
Whether to index the dataset after uploading |
True
|
is_create_if_not_exists
|
bool
|
Create the dataset if no match is found by name |
True
|
context
|
RouteContext | None
|
RouteContext for request configuration |
None
|
Returns:
| Type | Description |
|---|---|
ResponseGetData
|
ResponseGetData from the upload commit, with |
Raises:
| Type | Description |
|---|---|
DatasetNotFoundError
|
If no dataset matches and is_create_if_not_exists is False |
Source code in src/crew_dcs/routes/dataset/convenience.py
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 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |