Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,7 @@ I/O
- Bug in :meth:`set_option` where setting the pandas option ``display.html.use_mathjax`` to ``False`` has no effect (:issue:`59884`)
- Bug in :meth:`to_csv` where ``quotechar``` is not escaped when ``escapechar`` is not None (:issue:`61407`)
- Bug in :meth:`to_excel` where :class:`MultiIndex` columns would be merged to a single row when ``merge_cells=False`` is passed (:issue:`60274`)
- Bug in :meth:`~pandas.Series.info` where calling with ``show_counts=False`` raised a :exc:`ValueError` (:issue:`62590`)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good addition to the bug fixes section. It clearly describes the issue and references the relevant GitHub issue. However, to improve clarity and consistency, we could make a small adjustment to the wording.

Suggested change
- Bug in :meth:`~pandas.Series.info` where calling with ``show_counts=False`` raised a :exc:`ValueError` (:issue:`62590`)
- Bug in :meth:`Series.info` where calling with ``show_counts=False`` raised a :exc:`ValueError` (:issue:`62590`)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good addition to the whatsnew document. This correctly documents the bug fix for Series.info(show_counts=False) which was raising a ValueError.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job adding a clear and concise entry to the "whatsnew" documentation. The entry correctly describes the bug that was fixed (ValueError in Series.info when show_counts=False) and properly references the issue number.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whatsnew entry is properly formatted and placed in the correct I/O section. The description clearly explains the bug and references the correct issue number.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whatsnew entry is properly formatted and placed in the correct I/O section. The description clearly explains the bug and references the appropriate issue number.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appropriate documentation of the bug fix. The entry correctly references the issue number and describes the problem clearly.


Period
^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/formats/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ def headers(self) -> Sequence[str]:

def _gen_rows_without_counts(self) -> Iterator[Sequence[str]]:
"""Iterator with string representation of body data without counts."""
yield from self._gen_dtypes()
yield from ([dtype] for dtype in self._gen_dtypes())
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous implementation returns an iterator of strings directly from self._gen_dtypes(), but this causes a ValueError when show_counts=False since the _gen_rows_without_counts method should return sequences of strings, not individual strings. The fix correctly wraps each dtype in a list.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix! This change properly ensures that _gen_rows_without_counts() returns a sequence of sequences by wrapping each dtype in a list. The previous implementation was incorrectly yielding raw dtype values directly, causing the error when show_counts=False is specified.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the ValueError by wrapping each dtype string in a list to create a sequence. This ensures consistency with the expected return type of Iterator[Sequence[str]] and matches the pattern used in the DataFrame equivalent method.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the ValueError by wrapping each dtype in a list to create a sequence. This ensures consistency with the expected return type of Iterator[Sequence[str]] and matches the pattern used in the DataFrame equivalent method.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the ValueError by wrapping each dtype string in a list to create a sequence. This ensures consistency with the expected return type of Iterator[Sequence[str]] and matches the pattern used in _gen_rows_with_counts method.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the issue where _gen_rows_without_counts was yielding individual dtype strings instead of sequences. The method should yield sequences to match the expected table row format, which is what ([dtype] for dtype in self._gen_dtypes()) accomplishes. This ensures consistency with the _gen_rows_with_counts method that yields tuples from zip().

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the issue where Series.info(show_counts=False) was raising a ValueError. The problem was that _gen_rows_without_counts was yielding individual strings instead of sequences of strings.

The solution wraps each dtype string in a list to create the expected sequence format, which matches the pattern used in the DataFrame equivalent method _DataFrameTableBuilderVerbose._gen_rows_without_counts (lines 983-990).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the issue where Series.info(show_counts=False) was raising a ValueError. The problem was that _gen_rows_without_counts was yielding individual strings instead of sequences of strings.

The solution wraps each dtype string in a list to create the expected sequence format, which matches the pattern used in the DataFrame equivalent method _DataFrameTableBuilderVerbose._gen_rows_without_counts (lines 983-990).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix! The issue was that _gen_rows_without_counts was yielding individual strings instead of sequences of strings. The table builder expects each row to be a sequence (like a list or tuple) of column values, not individual strings.

The fix correctly wraps each dtype string in a list [dtype] to create the expected sequence format, which matches the pattern used in _gen_rows_with_counts method and the _DataFrameTableBuilderVerbose class.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix! The issue was that _gen_rows_without_counts was yielding individual dtype strings instead of sequences (rows). By wrapping each dtype in a list [dtype], you ensure that each yielded item is a sequence that matches the expected table row format. This is consistent with the pattern used in _gen_rows_with_counts and other similar methods in the codebase.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix! The issue was that _gen_rows_without_counts was yielding individual dtype strings instead of sequences (rows). By wrapping each dtype in a list [dtype], you ensure that each yielded item is a sequence that matches the expected table row format. This is consistent with the pattern used in _gen_rows_with_counts and other similar methods in the codebase.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the type mismatch issue. The method signature indicates it should return Iterator[Sequence[str]], but the original code was yielding individual strings from _gen_dtypes(). Wrapping each dtype in a list ensures the return type matches the expected interface and fixes the ValueError when show_counts=False.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the ValueError by wrapping each dtype in a list to match the expected sequence format. This is consistent with the _gen_rows_with_counts method which uses zip() to create tuples. The change ensures that each row is a sequence rather than a scalar value.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the ValueError by wrapping each dtype in a list to create proper sequences for the table builder. This change aligns with the expected format where each row should be a sequence of strings, not individual strings.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the ValueError by ensuring _gen_rows_without_counts returns sequences of strings rather than individual strings. This matches the expected interface for table builders where each row should be a sequence.

However, consider adding a test case to prevent regression of this bug. The fix looks correct but would benefit from test coverage to ensure Series.info(show_counts=False) works properly.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the issue where _gen_rows_without_counts was yielding individual strings instead of sequences of strings. The change wraps each dtype in a list [dtype] to ensure the method returns an iterator of sequences, which is consistent with the expected return type Iterator[Sequence[str]] and matches the behavior of _gen_rows_with_counts.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the issue by wrapping each dtype in a list to create proper sequence rows. This ensures consistency with the expected format for table building where each row should be a sequence of strings.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix! The change correctly wraps each dtype in a list to match the expected sequence format for table rows. This addresses the root cause of the ValueError when show_counts=False is used with Series.info().

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the type mismatch issue. The _gen_rows_without_counts method should yield sequences of strings (like tuples or lists) to match the expected interface, but self._gen_dtypes() yields individual strings. Wrapping each dtype in a list ensures consistency with the expected Iterator[Sequence[str]] return type.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the type mismatch issue. The method signature expects Iterator[Sequence[str]] but was yielding individual strings. Wrapping each dtype in a list creates the proper sequence structure that matches the expected return type and aligns with the pattern used in _gen_rows_with_counts.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the type mismatch issue. The method signature indicates it should return Iterator[Sequence[str]], but the original code was yielding individual strings instead of sequences. Wrapping each dtype in a list ensures the correct return type.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the ValueError by ensuring each dtype is wrapped in a sequence. The _gen_rows_without_counts method should yield sequences of strings (like _gen_rows_with_counts does), not individual strings. This change makes the Series info output consistent with the expected table format.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the ValueError by ensuring _gen_rows_without_counts returns an iterator of sequences rather than strings. This matches the expected format where each row should be a sequence of column values, consistent with _gen_rows_with_counts which uses zip() to create tuples.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the ValueError by wrapping each dtype in a list to create the expected sequence format. However, consider using a more explicit approach for better readability and consistency with the _gen_rows_with_counts method.

Suggested change
yield from ([dtype] for dtype in self._gen_dtypes())
for dtype in self._gen_dtypes():
yield [dtype]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the ValueError by ensuring each dtype is wrapped in a sequence. This matches the expected format for table rows and is consistent with the _gen_rows_with_counts method which uses zip() to create sequences.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the ValueError by ensuring each dtype is yielded as a sequence rather than a string. The _gen_rows_without_counts method should return an Iterator of sequences to match the return type annotation and be consistent with _gen_rows_with_counts.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the ValueError by ensuring each dtype is wrapped in a sequence. The _gen_rows_without_counts method should yield sequences of strings to match the expected format for table building, and this change ensures consistency with the _gen_rows_with_counts method which uses zip() to create tuples.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the type mismatch issue. The method signature indicates it should return Iterator[Sequence[str]], but the original code was yielding individual strings from _gen_dtypes(). Wrapping each dtype in a list ensures each yielded item is a sequence, which matches the expected return type and fixes the ValueError when show_counts=False.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the type mismatch issue. The method signature expects Iterator[Sequence[str]] but was yielding individual strings. Wrapping each dtype in a list creates the proper sequence structure that matches the expected return type and aligns with the pattern used in _gen_rows_with_counts.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the ValueError by wrapping each dtype in a list to create sequences. This ensures consistency with the expected return type Iterator[Sequence[str]] as defined in the method signature. The change aligns with the pattern used in _DataFrameTableBuilderVerbose._gen_rows_without_counts() which uses zip() to create tuples (sequences) of strings.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the ValueError by wrapping each dtype in a list to create the expected sequence format. This ensures consistency with the table builder's expectation that _gen_rows_without_counts yields sequences of strings rather than individual strings.


def _gen_rows_with_counts(self) -> Iterator[Sequence[str]]:
"""Iterator with string representation of body data with counts."""
Expand Down