mirror of
https://github.com/elastic/eland.git
synced 2025-07-24 00:00:39 +08:00
Fix 'Series.__repr__()' when the series is empty
This commit is contained in:
parent
54468cb85b
commit
95b8d75e37
@ -327,7 +327,7 @@ class Series(NDFrame):
|
|||||||
|
|
||||||
self.to_string(
|
self.to_string(
|
||||||
buf=buf,
|
buf=buf,
|
||||||
name=self.name,
|
name=True,
|
||||||
dtype=True,
|
dtype=True,
|
||||||
min_rows=min_rows,
|
min_rows=min_rows,
|
||||||
max_rows=max_rows,
|
max_rows=max_rows,
|
||||||
@ -393,6 +393,22 @@ class Series(NDFrame):
|
|||||||
else:
|
else:
|
||||||
_buf = StringIO()
|
_buf = StringIO()
|
||||||
|
|
||||||
|
if num_rows == 0:
|
||||||
|
# Empty series are rendered differently than
|
||||||
|
# series with items. We can luckily use our
|
||||||
|
# example series in this case.
|
||||||
|
temp_series.head(0).to_string(
|
||||||
|
buf=_buf,
|
||||||
|
na_rep=na_rep,
|
||||||
|
float_format=float_format,
|
||||||
|
header=header,
|
||||||
|
index=index,
|
||||||
|
length=length,
|
||||||
|
dtype=dtype,
|
||||||
|
name=name,
|
||||||
|
max_rows=max_rows,
|
||||||
|
)
|
||||||
|
else:
|
||||||
# Create repr of fake series without name, length, dtype summary
|
# Create repr of fake series without name, length, dtype summary
|
||||||
temp_series.to_string(
|
temp_series.to_string(
|
||||||
buf=_buf,
|
buf=_buf,
|
||||||
|
@ -39,3 +39,8 @@ class TestSeriesRepr(TestData):
|
|||||||
ed_repr = repr(ed_s)
|
ed_repr = repr(ed_s)
|
||||||
|
|
||||||
assert pd_repr == ed_repr
|
assert pd_repr == ed_repr
|
||||||
|
|
||||||
|
def test_repr_empty_series(self):
|
||||||
|
pd_s = self.pd_flights()["Carrier"].head(0)
|
||||||
|
ed_s = ed.Series(ES_TEST_CLIENT, FLIGHTS_INDEX_NAME, "Carrier").head(0)
|
||||||
|
assert repr(pd_s) == repr(ed_s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user