Skip to content

Commit

Permalink
Merge pull request #75 from lincc-frameworks/missed-values-packer
Browse files Browse the repository at this point in the history
  • Loading branch information
hombit authored May 10, 2024
2 parents c7612af + 074840f commit 0cfbe5f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/nested_pandas/series/packer.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,14 @@ def view_sorted_series_as_list_array(

list_array = pa.ListArray.from_arrays(
offset,
pa.array(series),
pa.array(series, from_pandas=True),
)
return pd.Series(
list_array,
dtype=pd.ArrowDtype(list_array.type),
index=unique_index,
copy=False,
name=series.name,
)


Expand Down
7 changes: 5 additions & 2 deletions tests/nested_pandas/series/test_packer.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,10 @@ def test_view_sorted_df_as_list_arrays():
def test_view_sorted_series_as_list_array():
"""Test view_sorted_series_as_list_array()."""
series = pd.Series(
data=[1, 2, 3, 4, 5, 6, 7, 8, 9],
data=[1, 2, 3, 4, 5, None, 7, 8, 9],
dtype=pd.Int64Dtype(),
index=[1, 1, 2, 2, 3, 3, 4, 4, 4],
name="my_series",
)
nested = packer.view_sorted_series_as_list_array(series)

Expand All @@ -376,10 +378,11 @@ def test_view_sorted_series_as_list_array():
data=[
np.array([1, 2]),
np.array([3, 4]),
np.array([5, 6]),
np.array([5, None]),
np.array([7, 8, 9]),
],
index=[1, 2, 3, 4],
dtype=pd.ArrowDtype(pa.list_(pa.int64())),
name="my_series",
)
assert_series_equal(nested, desired_nested)

0 comments on commit 0cfbe5f

Please sign in to comment.