nested-pandas 0.2.0__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.
Files changed (79) hide show
  1. {nested_pandas-0.2.0/src/nested_pandas.egg-info → nested_pandas-0.2.2}/PKG-INFO +1 -1
  2. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas/_version.py +2 -2
  3. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas/nestedframe/core.py +2 -1
  4. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas/series/accessor.py +19 -10
  5. {nested_pandas-0.2.0 → nested_pandas-0.2.2/src/nested_pandas.egg-info}/PKG-INFO +1 -1
  6. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/tests/nested_pandas/nestedframe/test_nestedframe.py +18 -0
  7. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/tests/nested_pandas/series/test_accessor.py +53 -0
  8. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.copier-answers.yml +0 -0
  9. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.git_archival.txt +0 -0
  10. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.gitattributes +0 -0
  11. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.github/ISSUE_TEMPLATE/0-general_issue.md +0 -0
  12. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.github/ISSUE_TEMPLATE/1-bug_report.md +0 -0
  13. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.github/ISSUE_TEMPLATE/2-feature_request.md +0 -0
  14. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.github/dependabot.yml +0 -0
  15. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.github/pull_request_template.md +0 -0
  16. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.github/workflows/asv-main.yml +0 -0
  17. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.github/workflows/asv-nightly.yml +0 -0
  18. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.github/workflows/asv-pr.yml +0 -0
  19. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.github/workflows/build-documentation.yml +0 -0
  20. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.github/workflows/pre-commit-ci.yml +0 -0
  21. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.github/workflows/publish-benchmarks-pr.yml +0 -0
  22. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.github/workflows/publish-to-pypi.yml +0 -0
  23. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.github/workflows/smoke-test.yml +0 -0
  24. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.github/workflows/testing-and-coverage.yml +0 -0
  25. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.gitignore +0 -0
  26. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.pre-commit-config.yaml +0 -0
  27. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.readthedocs.yml +0 -0
  28. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/.setup_dev.sh +0 -0
  29. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/LICENSE +0 -0
  30. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/README.md +0 -0
  31. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/benchmarks/__init__.py +0 -0
  32. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/benchmarks/asv.conf.json +0 -0
  33. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/benchmarks/benchmarks.py +0 -0
  34. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/docs/Makefile +0 -0
  35. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/docs/_static/custom.css +0 -0
  36. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/docs/conf.py +0 -0
  37. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/docs/gettingstarted/contributing.rst +0 -0
  38. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/docs/gettingstarted/installation.rst +0 -0
  39. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/docs/gettingstarted/quickstart.ipynb +0 -0
  40. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/docs/gettingstarted.rst +0 -0
  41. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/docs/index.rst +0 -0
  42. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/docs/requirements.txt +0 -0
  43. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/docs/tutorials/README.md +0 -0
  44. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/docs/tutorials/data_loading_notebook.ipynb +0 -0
  45. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/docs/tutorials/data_manipulation.ipynb +0 -0
  46. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/docs/tutorials/low_level.ipynb +0 -0
  47. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/docs/tutorials/nested_spectra.ipynb +0 -0
  48. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/docs/tutorials.rst +0 -0
  49. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/nestedframe.png +0 -0
  50. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/pyproject.toml +0 -0
  51. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/setup.cfg +0 -0
  52. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas/__init__.py +0 -0
  53. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas/datasets/__init__.py +0 -0
  54. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas/datasets/generation.py +0 -0
  55. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas/nestedframe/__init__.py +0 -0
  56. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas/nestedframe/io.py +0 -0
  57. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas/nestedframe/utils.py +0 -0
  58. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas/py.typed +0 -0
  59. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas/series/__init__.py +0 -0
  60. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas/series/dtype.py +0 -0
  61. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas/series/ext_array.py +0 -0
  62. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas/series/packer.py +0 -0
  63. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas/series/utils.py +0 -0
  64. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas/utils/__init__.py +0 -0
  65. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas/utils/utils.py +0 -0
  66. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas.egg-info/SOURCES.txt +0 -0
  67. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas.egg-info/dependency_links.txt +0 -0
  68. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas.egg-info/requires.txt +0 -0
  69. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/src/nested_pandas.egg-info/top_level.txt +0 -0
  70. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/tests/nested_pandas/conftest.py +0 -0
  71. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/tests/nested_pandas/datasets/test_generation.py +0 -0
  72. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/tests/nested_pandas/e2e_tests/test_issue89.py +0 -0
  73. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/tests/nested_pandas/nestedframe/test_io.py +0 -0
  74. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/tests/nested_pandas/nestedframe/test_nestedframe_utils.py +0 -0
  75. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/tests/nested_pandas/series/test_dtype.py +0 -0
  76. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/tests/nested_pandas/series/test_ext_array.py +0 -0
  77. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/tests/nested_pandas/series/test_packer.py +0 -0
  78. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/tests/nested_pandas/test_packaging.py +0 -0
  79. {nested_pandas-0.2.0 → nested_pandas-0.2.2}/tests/nested_pandas/utils/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nested-pandas
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Author-email: LINCC Frameworks <brantd@uw.edu>
5
5
  License: MIT License
6
6
 
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.2.0'
16
- __version_tuple__ = version_tuple = (0, 2, 0)
15
+ __version__ = version = '0.2.2'
16
+ __version_tuple__ = version_tuple = (0, 2, 2)
@@ -211,7 +211,8 @@ class NestedFrame(pd.DataFrame):
211
211
  out_df = df[base_columns][~df.index.duplicated(keep="first")]
212
212
 
213
213
  # add nested
214
- nested_columns = [col for col in df.columns if col not in base_columns]
214
+ if nested_columns is None:
215
+ nested_columns = [col for col in df.columns if col not in base_columns]
215
216
  return out_df.add_nested(df[nested_columns], name=name)
216
217
 
217
218
  @classmethod
@@ -251,14 +251,18 @@ class NestSeriesAccessor(Mapping):
251
251
  The flat-array field.
252
252
  """
253
253
 
254
- # TODO: we should make proper missed values handling here
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
- flat_array,
261
- dtype=pd.ArrowDtype(flat_array.type),
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
- struct_array = cast(pa.StructArray, pa.array(self._series))
281
- list_array = struct_array.field(field)
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
- list_array,
284
- dtype=pd.ArrowDtype(list_array.type),
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,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nested-pandas
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Author-email: LINCC Frameworks <brantd@uw.edu>
5
5
  License: MIT License
6
6
 
@@ -320,6 +320,24 @@ def test_recover_from_flat():
320
320
  assert nf2.equals(nf)
321
321
 
322
322
 
323
+ def test_from_flat_omitting_columns():
324
+ """test that from_flat successfully produces subsets"""
325
+ flat = NestedFrame(
326
+ {"a": [1, 1, 1, 2, 2], "b": [2, 2, 2, 4, 4], "c": [1, 2, 3, 4, 5], "d": [2, 4, 6, 8, 10]},
327
+ index=[0, 0, 0, 1, 1],
328
+ )
329
+
330
+ # omit a base column
331
+ nf = NestedFrame.from_flat(flat, base_columns=["b"], nested_columns=["c", "d"])
332
+ assert list(nf.columns) == ["b", "nested"]
333
+ assert list(nf.nested.nest.fields) == ["c", "d"]
334
+
335
+ # omit a nested column
336
+ nf = NestedFrame.from_flat(flat, base_columns=["a", "b"], nested_columns=["c"])
337
+ assert list(nf.columns) == ["a", "b", "nested"]
338
+ assert list(nf.nested.nest.fields) == ["c"]
339
+
340
+
323
341
  def test_from_lists():
324
342
  """Test NestedFrame.from_lists behavior"""
325
343
  nf = NestedFrame(
@@ -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