Skip to content

Commit b176739

Browse files
authored
Merge pull request #325 from lincc-frameworks/fix_flat_inner_docstring
fix spacing for to_flatten_inner docstring
2 parents f28da17 + 9a7bfc7 commit b176739

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/nested_pandas/series/accessor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,11 +571,13 @@ def to_flatten_inner(self, field: str) -> pd.Series:
571571
572572
Examples
573573
--------
574+
574575
>>> from nested_pandas import NestedFrame
575576
>>> from nested_pandas.datasets import generate_data
576577
>>> nf = generate_data(5, 2, seed=1).rename(columns={"nested": "inner"})
577578
578579
Assign a repeated ID to double-nest on
580+
579581
>>> nf["id"] = [0, 0, 0, 1, 1]
580582
>>> nf
581583
a b inner id
@@ -584,6 +586,7 @@ def to_flatten_inner(self, field: str) -> pd.Series:
584586
2 0.000114 0.691121 [{t: 4.089045, flux: 31.342418, band: 'g'}; …]... 0
585587
3 0.302333 0.793535 [{t: 17.562349, flux: 69.232262, band: 'r'}; …... 1
586588
4 0.146756 1.077633 [{t: 0.547752, flux: 87.638915, band: 'g'}; …]... 1
589+
587590
>>> nf.inner.nest.to_flat()
588591
t flux band
589592
0 8.38389 80.074457 r
@@ -598,16 +601,19 @@ def to_flatten_inner(self, field: str) -> pd.Series:
598601
4 3.96203 87.81425 r
599602
600603
Create a dataframe with double-nested column "outer"
604+
601605
>>> dnf = NestedFrame.from_flat(nf, base_columns=[], on="id", name="outer")
602606
603607
Flat "inner" nested column.
604608
This is like "concatenation" of the initial nf frame on duplicated `id` rows
609+
605610
>>> concated_nf_series = dnf["outer"].nest.to_flatten_inner("inner")
606611
>>> concated_nf_series
607612
id
608613
0 [{a: 0.417022, b: 0.184677, t: 8.38389, flux: ...
609614
1 [{a: 0.302333, b: 0.793535, t: 17.562349, flux...
610615
Name: outer, dtype: nested<a: [double], b: [double], t: [double], flux: [double], band: [string]>
616+
611617
>>> concated_nf_series.nest.to_flat() # doctest: +NORMALIZE_WHITESPACE
612618
a b t flux band
613619
id

0 commit comments

Comments
 (0)