Skip to content

Commit 6a2bd1b

Browse files
committed
Formatting
1 parent fe45496 commit 6a2bd1b

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

src/nested_pandas/nestedframe/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def add_nested(
271271
- inner: form intersection of calling frame's index with other
272272
frame's index, preserving the order of the calling index.
273273
on : str, default: None
274-
A column in the list
274+
A column in the list
275275
dtype : dtype or None
276276
NestedDtype to use for the nested column; pd.ArrowDtype or
277277
pa.DataType can also be used to specify the nested dtype. If None,

tests/nested_pandas/nestedframe/test_nestedframe.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
import pandas as pd
33
import pyarrow as pa
44
import pytest
5-
from pandas.testing import assert_frame_equal
6-
75
from nested_pandas import NestedFrame
86
from nested_pandas.datasets import generate_data
97
from nested_pandas.nestedframe.core import _SeriesFromNest
8+
from pandas.testing import assert_frame_equal
109

1110

1211
def test_nestedframe_construction():
@@ -188,8 +187,7 @@ def test_add_nested_with_flat_df():
188187
def test_add_nested_with_flat_df_and_mismatched_index():
189188
"""Test add_nested when index values of base are missing matches in nested"""
190189

191-
base = NestedFrame(
192-
data={"a": [1, 2, 3], "b": [2, 4, 6], "new_index": [0, 1, 3] }, index=[0, 1, 2])
190+
base = NestedFrame(data={"a": [1, 2, 3], "b": [2, 4, 6], "new_index": [0, 1, 3]}, index=[0, 1, 2])
193191

194192
nested = pd.DataFrame(
195193
data={
@@ -378,6 +376,7 @@ def test_add_nested_with_flat_df_and_mismatched_index():
378376
# we know that none of the joined values should be none
379377
assert not inner_res_on.isnull().values.any()
380378

379+
381380
def test_add_nested_with_series():
382381
"""Test that add_nested correctly adds a nested column to the base df"""
383382

tests/nested_pandas/series/test_accessor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1+
import nested_pandas as npd
12
import numpy as np
23
import pandas as pd
34
import pyarrow as pa
45
import pytest
5-
from numpy.testing import assert_array_equal
6-
from pandas.testing import assert_frame_equal, assert_index_equal, assert_series_equal
7-
8-
import nested_pandas as npd
96
from nested_pandas import NestedDtype
107
from nested_pandas.series.ext_array import NestedExtensionArray
118
from nested_pandas.series.packer import pack_flat, pack_seq
9+
from numpy.testing import assert_array_equal
10+
from pandas.testing import assert_frame_equal, assert_index_equal, assert_series_equal
1211

1312

1413
def test_registered():
@@ -983,10 +982,11 @@ def test_values():
983982
for value in series.nest.values():
984983
assert_series_equal(value, series.nest[value.name])
985984

985+
986986
def test_get_list_index():
987987
"""Test that the get_list_index() method works."""
988988
# First check that an empty NestedSeries returns an empty list index.
989-
empty_struct_array = pa.StructArray.from_arrays(arrays=[],names=[])
989+
empty_struct_array = pa.StructArray.from_arrays(arrays=[], names=[])
990990
empty_series = pd.Series(empty_struct_array, dtype=NestedDtype(empty_struct_array.type), index=[])
991991
assert len(empty_series) == 0
992992
assert len(empty_series.array.get_list_index()) == 0

tests/nested_pandas/series/test_packer.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
import pandas as pd
33
import pyarrow as pa
44
import pytest
5-
from numpy.testing import assert_array_equal
6-
from pandas.testing import assert_frame_equal, assert_series_equal
7-
85
from nested_pandas import NestedDtype
96
from nested_pandas.series import packer
7+
from numpy.testing import assert_array_equal
8+
from pandas.testing import assert_frame_equal, assert_series_equal
109

1110

1211
def offsets_reused(nested_series):
@@ -67,6 +66,7 @@ def test_pack_with_flat_df_and_index():
6766
offsets_reused(series)
6867
assert_series_equal(series, desired)
6968

69+
7070
def test_pack_with_flat_df_and_on():
7171
"""Test packing a dataframe on a column"""
7272
df = pd.DataFrame(
@@ -97,6 +97,7 @@ def test_pack_with_flat_df_and_on():
9797
offsets_reused(series)
9898
assert_series_equal(series, desired)
9999

100+
100101
def test_pack_with_flat_df_and_on_and_index():
101102
"""Test packing a dataframe on a column while also specifying an index"""
102103
df = pd.DataFrame(
@@ -125,6 +126,7 @@ def test_pack_with_flat_df_and_on_and_index():
125126
offsets_reused(series)
126127
assert_series_equal(series, desired)
127128

129+
128130
def test_pack_with_series_of_dfs():
129131
"""Test pack(pd.Series([pd.DataFrame(), ...]))."""
130132
input_series = pd.Series(
@@ -184,6 +186,7 @@ def test_pack_flat():
184186
offsets_reused(actual)
185187
assert_series_equal(actual, desired)
186188

189+
187190
def test_pack_flat_with_on():
188191
"""Test pack_flat() where you pack on a given column."""
189192
df = pd.DataFrame(
@@ -202,13 +205,13 @@ def test_pack_flat_with_on():
202205
# Index 0: # All of the values where column 'c' is 0
203206
(
204207
np.array([8, 1, 3, 5]), # values from column 'a'
205-
np.array([1, 0, 0, 0]) # values from column 'b'
208+
np.array([1, 0, 0, 0]), # values from column 'b'
206209
),
207210
# Index 1: # All of the values where column 'c' is 1
208211
(
209212
np.array([7, 9, 2, 4, 6]), # values from column 'a'
210-
np.array([0, 0, 1, 1, 1]) # values from column 'b'
211-
)
213+
np.array([0, 0, 1, 1, 1]), # values from column 'b'
214+
),
212215
],
213216
index=[0, 1],
214217
dtype=NestedDtype.from_fields(dict(a=pa.int64(), b=pa.int64())),
@@ -217,6 +220,7 @@ def test_pack_flat_with_on():
217220
offsets_reused(actual)
218221
assert_series_equal(actual, desired)
219222

223+
220224
def test_pack_sorted_df_into_struct():
221225
"""Test pack_sorted_df_into_struct()."""
222226
df = pd.DataFrame(

0 commit comments

Comments
 (0)