Skip to content

Commit

Permalink
Pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonbb committed May 16, 2024
1 parent ac8dd7e commit 0439298
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/nested_pandas/datasets/generation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import numpy as np

from nested_pandas import NestedFrame
Expand Down Expand Up @@ -55,6 +54,7 @@ def generate_data(n_base, n_layer, seed=None) -> NestedFrame:
else:
raise TypeError("Input to n_layer is not an int or dict.")


def generate_parquet_file(n_base, n_layer, path, file_per_layer=False, seed=None):
"""Generates a toy dataset and outputs it to one or more parquet files.
Expand Down
6 changes: 3 additions & 3 deletions src/nested_pandas/nestedframe/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def translate_cols(frame, layer, col):
)
return result

def to_parquet(self, path, by_layer=False, **kwargs) -> NestedFrame:
def to_parquet(self, path, by_layer=False, **kwargs) -> None:
"""Creates parquet file(s) with the data of a NestedFrame, either
as a single parquet file where each nested dataset is packed into its
own column or as an individual parquet file for each layer.
Expand Down Expand Up @@ -485,5 +485,5 @@ def to_parquet(self, path, by_layer=False, **kwargs) -> NestedFrame:
for layer in self.all_columns:
if layer != "base":
path_layer = os.path.join(path, f"{layer}.parquet")
self[layer].nest.to_flat().to_parquet(path_layer, engine='pyarrow', **kwargs)
return None
self[layer].nest.to_flat().to_parquet(path_layer, engine="pyarrow", **kwargs)
return None
6 changes: 4 additions & 2 deletions tests/nested_pandas/nestedframe/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_read_parquet(tmp_path, columns, pack_columns):


def test_write_packed_parquet():
"""Tests writing a nested frame to a single parquet file. """
"""Tests writing a nested frame to a single parquet file."""
# Generate some test data
base = pd.DataFrame(data={"a": [1, 2, 3], "b": [2, 4, 6]}, index=[0, 1, 2])

Expand All @@ -73,7 +73,8 @@ def test_write_packed_parquet():

nested2 = pd.DataFrame(
data={"e": [0, 2, 4, 1, 4, 3, 1, 4, 1], "f": [5, 4, 7, 5, 3, 1, 9, 3, 4]},
index=[0, 0, 0, 1, 1, 1, 2, 2, 2], )
index=[0, 0, 0, 1, 1, 1, 2, 2, 2],
)

# Construct the NestedFrame
nf = NestedFrame(base).add_nested(nested1, name="nested1").add_nested(nested2, name="nested2")
Expand All @@ -86,6 +87,7 @@ def test_write_packed_parquet():
nf2 = read_parquet(temp.name)
assert_frame_equal(nf, nf2)


def test_write_parquet_by_layer():
"""Tests writing a nested frame to multiple parquet files."""
base = pd.DataFrame(data={"a": [1, 2, 3], "b": [2, 4, 6]}, index=[0, 1, 2])
Expand Down

0 comments on commit 0439298

Please sign in to comment.