maxframe.dataframe.DataFrame.to_odps_table#

DataFrame.to_odps_table(table: Table | str, partition: str | None = None, partition_col: None | str | List[str] = None, overwrite: bool = False, unknown_as_string: bool | None = None, index: bool = True, index_label: None | str | List[str] = None, lifecycle: int | None = None)#

Write DataFrame object into a MaxCompute (ODPS) table.

You need to provide the name of the table to write to. If you want to store data into a specific partitioned of a table, argument partition can be used. You can also use partition_col to specify DataFrame columns as partition columns, and data in the DataFrame will be grouped by these columns and inserted into partitions the values of these columns.

If the table does not exist, to_odps_table will create one.

Column names for indexes is determined by index_label argument. If the argument is absent, names of the levels is used if they are not None, or default names will be used. The default name for indexes with only one level will be index, and for indexes with multiple levels, the name will be level_x while x is the index of the level.

Parameters:
  • table (str) – Name ot the table to write DataFrame into

  • partition (Optional[str]) – Spec of the partition to write to, can be ‘pt1=xxx,pt2=yyy’

  • partition_col (Union[None, str, List[str]]) – Name of columns in DataFrame as partition columns.

  • overwrite (bool) – Overwrite data if the table / partition already exists.

  • unknown_as_string (bool) – If True, object type in the DataFrame will be treated as strings. Otherwise errors might be raised.

  • index (bool) – If True, indexes will be stored. Otherwise they are ignored.

  • index_label (Union[None, str, List[str]]) – Specify column names for index levels. If absent, level names or default names will be used.

  • lifecycle (Optional[int]) – Specify lifecycle of the output table.

Returns:

result – Stub DataFrame for execution.

Return type:

DataFrame

Notes

to_odps_table returns a stub object for execution. The result returned is not reusable.

Examples