Skip to content

BUG: inconsistent behaviour of min_rows and max_rows in dataframe to_string in pd 3.0.1 #64824

@rizac

Description

@rizac

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

print(pd.DataFrame([{'a': 1.1}]*10).to_string(max_rows=5, min_rows=1))
      a
0   1.1
1   1.1
2   1.1
3   1.1
4   1.1
..  ...

Issue Description

When i provide min_rows=1 in dataframe.to_string, i should see The number of rows to display in the console in a truncated repr (when number of rows is above max_rows)..
However, in my example the number of rows displayed are the first 5 instead of only 1. By seting min_rows=2 the behaviour is consistent with the doc.

Side note: I am unsure if this is really a bug, or a hidden feature that should simply be documented: by setting min_rows=1 I could actually get what I was trying to achieve, i.e., display truncated dataframes by showing the first N rows + "...", instead of breaking into two chunks separated by "...". so, if this is a bug side effect, I would be nice to have it as feature

Thank you

Expected Behavior

     a
0   1.1
..  ...

Installed Versions

Details

3.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions