From 92566a38bfb9b8cc8267077c33696133d0affd0f Mon Sep 17 00:00:00 2001 From: David Vegh Date: Tue, 22 Aug 2023 07:46:25 +0200 Subject: [PATCH] Fixed: add missing `max_rows` parameter to `add_df_index` function --- src/ipyvizzu/animation.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ipyvizzu/animation.py b/src/ipyvizzu/animation.py index 8e2fd935..e1a1ab83 100644 --- a/src/ipyvizzu/animation.py +++ b/src/ipyvizzu/animation.py @@ -299,7 +299,8 @@ def add_df( The default measure value to fill empty values. Defaults to 0. default_dimension_value: The default dimension value to fill empty values. Defaults to an empty string. - max_rows: The maximum number of rows to include in the converted series list. + max_rows: + The maximum number of rows to include in the converted series list. If the `df` contains more rows, a random sample of the given number of rows (approximately) will be taken. include_index: @@ -383,6 +384,7 @@ def add_df_index( self, df: Optional[Union["pandas.DataFrame", "pandas.Series"]], # type: ignore column_name: str = "Index", + max_rows: int = MAX_ROWS, ) -> None: """ Add the index of a `pandas` `DataFrame` as a series to an existing @@ -393,6 +395,10 @@ def add_df_index( The `pandas` `DataFrame` or `Series` from which to extract the index. column_name: Name for the index column to add as a series. + max_rows: + The maximum number of rows to include in the converted series list. + If the `df` contains more rows, + a random sample of the given number of rows (approximately) will be taken. Example: Adding a data frame's index to a @@ -408,7 +414,9 @@ def add_df_index( """ if not isinstance(df, type(None)): - converter = PandasDataFrameConverter(df, include_index=column_name) + converter = PandasDataFrameConverter( + df, max_rows=max_rows, include_index=column_name + ) series_list = converter.get_series_from_index() self.add_series_list(series_list)