nested-pandas 0.2.1__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nested_pandas-0.2.1/src/nested_pandas.egg-info → nested_pandas-0.2.2}/PKG-INFO +1 -1
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas/_version.py +2 -2
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas/series/accessor.py +19 -10
- {nested_pandas-0.2.1 → nested_pandas-0.2.2/src/nested_pandas.egg-info}/PKG-INFO +1 -1
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/tests/nested_pandas/series/test_accessor.py +53 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.copier-answers.yml +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.git_archival.txt +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.gitattributes +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.github/ISSUE_TEMPLATE/0-general_issue.md +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.github/ISSUE_TEMPLATE/1-bug_report.md +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.github/ISSUE_TEMPLATE/2-feature_request.md +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.github/dependabot.yml +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.github/pull_request_template.md +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.github/workflows/asv-main.yml +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.github/workflows/asv-nightly.yml +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.github/workflows/asv-pr.yml +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.github/workflows/build-documentation.yml +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.github/workflows/pre-commit-ci.yml +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.github/workflows/publish-benchmarks-pr.yml +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.github/workflows/publish-to-pypi.yml +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.github/workflows/smoke-test.yml +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.github/workflows/testing-and-coverage.yml +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.gitignore +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.pre-commit-config.yaml +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.readthedocs.yml +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/.setup_dev.sh +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/LICENSE +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/README.md +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/benchmarks/__init__.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/benchmarks/asv.conf.json +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/benchmarks/benchmarks.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/docs/Makefile +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/docs/_static/custom.css +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/docs/conf.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/docs/gettingstarted/contributing.rst +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/docs/gettingstarted/installation.rst +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/docs/gettingstarted/quickstart.ipynb +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/docs/gettingstarted.rst +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/docs/index.rst +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/docs/requirements.txt +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/docs/tutorials/README.md +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/docs/tutorials/data_loading_notebook.ipynb +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/docs/tutorials/data_manipulation.ipynb +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/docs/tutorials/low_level.ipynb +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/docs/tutorials/nested_spectra.ipynb +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/docs/tutorials.rst +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/nestedframe.png +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/pyproject.toml +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/setup.cfg +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas/__init__.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas/datasets/__init__.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas/datasets/generation.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas/nestedframe/__init__.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas/nestedframe/core.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas/nestedframe/io.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas/nestedframe/utils.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas/py.typed +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas/series/__init__.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas/series/dtype.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas/series/ext_array.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas/series/packer.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas/series/utils.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas/utils/__init__.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas/utils/utils.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas.egg-info/SOURCES.txt +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas.egg-info/dependency_links.txt +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas.egg-info/requires.txt +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/src/nested_pandas.egg-info/top_level.txt +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/tests/nested_pandas/conftest.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/tests/nested_pandas/datasets/test_generation.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/tests/nested_pandas/e2e_tests/test_issue89.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/tests/nested_pandas/nestedframe/test_io.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/tests/nested_pandas/nestedframe/test_nestedframe.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/tests/nested_pandas/nestedframe/test_nestedframe_utils.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/tests/nested_pandas/series/test_dtype.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/tests/nested_pandas/series/test_ext_array.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/tests/nested_pandas/series/test_packer.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/tests/nested_pandas/test_packaging.py +0 -0
- {nested_pandas-0.2.1 → nested_pandas-0.2.2}/tests/nested_pandas/utils/test_utils.py +0 -0
|
@@ -251,14 +251,18 @@ class NestSeriesAccessor(Mapping):
|
|
|
251
251
|
The flat-array field.
|
|
252
252
|
"""
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
flat_chunks = []
|
|
255
|
+
for nested_chunk in self._series.array._chunked_array.iterchunks():
|
|
256
|
+
struct_array = cast(pa.StructArray, nested_chunk)
|
|
257
|
+
list_array = cast(pa.ListArray, struct_array.field(field))
|
|
258
|
+
flat_array = list_array.flatten()
|
|
259
|
+
flat_chunks.append(flat_array)
|
|
260
|
+
|
|
261
|
+
flat_chunked_array = pa.chunked_array(flat_chunks)
|
|
255
262
|
|
|
256
|
-
struct_array = cast(pa.StructArray, pa.array(self._series))
|
|
257
|
-
list_array = cast(pa.ListArray, struct_array.field(field))
|
|
258
|
-
flat_array = list_array.flatten()
|
|
259
263
|
return pd.Series(
|
|
260
|
-
|
|
261
|
-
dtype=pd.ArrowDtype(
|
|
264
|
+
flat_chunked_array,
|
|
265
|
+
dtype=pd.ArrowDtype(flat_chunked_array.type),
|
|
262
266
|
index=self.get_flat_index(),
|
|
263
267
|
name=field,
|
|
264
268
|
copy=False,
|
|
@@ -277,11 +281,16 @@ class NestSeriesAccessor(Mapping):
|
|
|
277
281
|
pd.Series
|
|
278
282
|
The list-array field.
|
|
279
283
|
"""
|
|
280
|
-
|
|
281
|
-
|
|
284
|
+
|
|
285
|
+
list_chunks = []
|
|
286
|
+
for nested_chunk in self._series.array._chunked_array.iterchunks():
|
|
287
|
+
struct_array = cast(pa.StructArray, nested_chunk)
|
|
288
|
+
list_array = struct_array.field(field)
|
|
289
|
+
list_chunks.append(list_array)
|
|
290
|
+
list_chunked_array = pa.chunked_array(list_chunks)
|
|
282
291
|
return pd.Series(
|
|
283
|
-
|
|
284
|
-
dtype=pd.ArrowDtype(
|
|
292
|
+
list_chunked_array,
|
|
293
|
+
dtype=pd.ArrowDtype(list_chunked_array.type),
|
|
285
294
|
index=self._series.index,
|
|
286
295
|
name=field,
|
|
287
296
|
copy=False,
|
|
@@ -543,6 +543,32 @@ def test_get_list_series():
|
|
|
543
543
|
)
|
|
544
544
|
|
|
545
545
|
|
|
546
|
+
def test_get_list_series_multiple_chunks():
|
|
547
|
+
"""Test that .nest.get_list_series() works when underlying array is chunked"""
|
|
548
|
+
struct_array = pa.StructArray.from_arrays(
|
|
549
|
+
arrays=[
|
|
550
|
+
[np.array([1, 2, 3]), np.array([4, 5, 6])],
|
|
551
|
+
[np.array([6, 4, 2]), np.array([1, 2, 3])],
|
|
552
|
+
],
|
|
553
|
+
names=["a", "b"],
|
|
554
|
+
)
|
|
555
|
+
chunked_array = pa.chunked_array([struct_array] * 3)
|
|
556
|
+
series = pd.Series(chunked_array, dtype=NestedDtype(chunked_array.type), index=[5, 7, 9, 11, 13, 15])
|
|
557
|
+
assert series.array.num_chunks == 3
|
|
558
|
+
|
|
559
|
+
lists = series.nest.get_list_series("a")
|
|
560
|
+
|
|
561
|
+
assert_series_equal(
|
|
562
|
+
lists,
|
|
563
|
+
pd.Series(
|
|
564
|
+
data=[np.array([1, 2, 3]), np.array([4, 5, 6])] * 3,
|
|
565
|
+
dtype=pd.ArrowDtype(pa.list_(pa.int64())),
|
|
566
|
+
index=[5, 7, 9, 11, 13, 15],
|
|
567
|
+
name="a",
|
|
568
|
+
),
|
|
569
|
+
)
|
|
570
|
+
|
|
571
|
+
|
|
546
572
|
def test_get():
|
|
547
573
|
"""Test .nest.get() which is implemented by the base class"""
|
|
548
574
|
series = pack_seq(
|
|
@@ -588,6 +614,33 @@ def test___getitem___single_field():
|
|
|
588
614
|
)
|
|
589
615
|
|
|
590
616
|
|
|
617
|
+
def test___getitem___single_field_multiple_chunks():
|
|
618
|
+
"""Reproduces issue 142
|
|
619
|
+
|
|
620
|
+
https://github.com/lincc-frameworks/nested-pandas/issues/142
|
|
621
|
+
"""
|
|
622
|
+
struct_array = pa.StructArray.from_arrays(
|
|
623
|
+
arrays=[
|
|
624
|
+
[np.array([1.0, 2.0, 3.0]), np.array([1.0, 2.0, 1.0])],
|
|
625
|
+
[np.array([4.0, 5.0, 6.0]), np.array([3.0, 4.0, 5.0])],
|
|
626
|
+
],
|
|
627
|
+
names=["a", "b"],
|
|
628
|
+
)
|
|
629
|
+
chunked_array = pa.chunked_array([struct_array] * 3)
|
|
630
|
+
series = pd.Series(chunked_array, dtype=NestedDtype(chunked_array.type), index=[0, 1, 2, 3, 4, 5])
|
|
631
|
+
assert series.array.num_chunks == 3
|
|
632
|
+
|
|
633
|
+
assert_series_equal(
|
|
634
|
+
series.nest["a"],
|
|
635
|
+
pd.Series(
|
|
636
|
+
np.array([1.0, 2.0, 3.0, 1.0, 2.0, 1.0] * 3),
|
|
637
|
+
dtype=pd.ArrowDtype(pa.float64()),
|
|
638
|
+
index=[0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],
|
|
639
|
+
name="a",
|
|
640
|
+
),
|
|
641
|
+
)
|
|
642
|
+
|
|
643
|
+
|
|
591
644
|
def test___getitem___multiple_fields():
|
|
592
645
|
"""Test that the .nest[["b", "a"]] works for multiple fields."""
|
|
593
646
|
arrays = [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nested_pandas-0.2.1 → nested_pandas-0.2.2}/tests/nested_pandas/nestedframe/test_nestedframe.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|