Skip to content

Bug fix - extension array with 2d datetime64 #46140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

weikhor
Copy link
Contributor

@weikhor weikhor commented Feb 24, 2022

@weikhor weikhor changed the title Bug extension array with 2 d datetime64 Bug fix extension array with 2d datetime64 Feb 24, 2022
@jreback jreback added ExtensionArray Extending pandas with custom dtypes or arrays. Output-Formatting __repr__ of pandas objects, to_string labels Feb 27, 2022
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

does this change user visible formatting or just with the internal formatters?

@weikhor weikhor closed this Feb 27, 2022
@weikhor weikhor reopened this Feb 27, 2022
@weikhor weikhor changed the title Bug fix extension array with 2d datetime64 Bug fix - extension array with 2d datetime64 Feb 27, 2022
@weikhor
Copy link
Contributor Author

weikhor commented Feb 27, 2022

does this change user visible formatting or just with the internal formatters?
@jreback Hi code changes with the internal formatters

@weikhor
Copy link
Contributor Author

weikhor commented Feb 28, 2022

Hi, I am still stuck in the PR. Need more time.

@weikhor weikhor requested review from jbrockmendel and jreback March 9, 2022 16:34
@jreback jreback added this to the 1.5 milestone Mar 16, 2022
@jreback
Copy link
Contributor

jreback commented Mar 16, 2022

@jbrockmendel ok here?

@weikhor if you can merge master

@jbrockmendel
Copy link
Member

will take another look today or tomorrow

nested_formatter = GenericArrayFormatter(fmt_values)
return list(nested_formatter.get_result())

return list(fmt_values)
Copy link
Member

Choose a reason for hiding this comment

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

why is anything necessary between L1630-L1640? we know we have DatetimeIndex which is 1D.

@@ -3158,6 +3158,97 @@ def format_func(x):
result = formatter.get_result()
assert result == ["10:10", "12:12"]

def test_datetime64formatter_2d_array(self):
# GH#38390
x = date_range("2018-01-01", periods=10, freq="H").to_numpy()
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: pls avoid 1-letter variable names. for date_range i like "dti"


values = self.values
if not isinstance(values, DatetimeIndex):
values = DatetimeIndex(values)
Copy link
Member

Choose a reason for hiding this comment

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

OK, so there is a deeper bug here in that DatetimeIndex(values) isn't raising when passed a 2D array.

@@ -1621,18 +1621,23 @@ def __init__(

def _format_strings(self) -> list[str]:
"""we by definition have DO NOT have a TZ"""
values = self.values
Copy link
Member

Choose a reason for hiding this comment

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

what is the scenario in which we get here with non-1D values? could we just assert 1d-ness at the top and not worry about the rest?

@weikhor
Copy link
Contributor Author

weikhor commented Mar 19, 2022

Hi It is difficult for me to answer questions provided. I need more time.

@weikhor
Copy link
Contributor Author

weikhor commented Apr 9, 2022

I close this since I stuck this for long time. I get simpler task. Thank for review.

@weikhor weikhor closed this Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: ExtensionArray with 2D datetime64 values errors on display formatting
3 participants