(scope, df, ptr_columns=(), legacy=True)
| 40 | |
| 41 | |
| 42 | def static_table_from_pandas(scope, df, ptr_columns=(), legacy=True): |
| 43 | for column in ptr_columns: |
| 44 | df[column] = df[column].apply(api.unsafe_make_pointer) |
| 45 | |
| 46 | schema = schema_from_pandas(df) |
| 47 | |
| 48 | columns: list[api.ColumnProperties] = [] |
| 49 | |
| 50 | for col in schema.columns().values(): |
| 51 | columns.append( |
| 52 | api.ColumnProperties( |
| 53 | dtype=col.dtype.to_engine(), |
| 54 | append_only=col.append_only, |
| 55 | ) |
| 56 | ) |
| 57 | |
| 58 | connector_properties = api.ConnectorProperties( |
| 59 | unsafe_trusted_ids=True, |
| 60 | column_properties=columns, |
| 61 | ) |
| 62 | |
| 63 | table = api.static_table_from_pandas( |
| 64 | scope, |
| 65 | df, |
| 66 | connector_properties, |
| 67 | ) |
| 68 | if legacy: |
| 69 | table = table_to_legacy(scope, table, len(df.columns)) |
| 70 | return table |
| 71 | |
| 72 | |
| 73 | def convert_table(scope, table): |
no test coverage detected