Skip to content

Commit

Permalink
Merge pull request #261 from vizzuhq/add_df_index
Browse files Browse the repository at this point in the history
Fixed: add missing `max_rows` parameter to `add_df_index` function
  • Loading branch information
veghdev committed Aug 22, 2023
2 parents ccd8ba7 + 92566a3 commit 2799336
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/ipyvizzu/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit 2799336

Please sign in to comment.