Skip to content

Commit

Permalink
Fixes Pandas CSV Reader Writer names
Browse files Browse the repository at this point in the history
CSV was not capitalized. Fixing that.
  • Loading branch information
skrawcz committed Oct 24, 2023
1 parent 7c6f488 commit 16bb3bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions hamilton/plugins/pandas_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def save_data(self, data: DATAFRAME_TYPE) -> Dict[str, Any]:


@dataclasses.dataclass
class PandasCsvReader(DataLoader):
class PandasCSVReader(DataLoader):
"""
Class that handles saving CSV files with pandas.
Maps to https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html
Expand Down Expand Up @@ -251,8 +251,8 @@ def name(cls) -> str:


@dataclasses.dataclass
class PandasCsvWriter(DataSaver):
"""Class that handles saving Csv files with pandas.
class PandasCSVWriter(DataSaver):
"""Class that handles saving CSV files with pandas.
Maps to https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_csv.html
"""

Expand Down Expand Up @@ -1323,8 +1323,8 @@ def name(cls) -> str:
def register_data_loaders():
"""Function to register the data loaders for this extension."""
for loader in [
PandasCsvReader,
PandasCsvWriter,
PandasCSVReader,
PandasCSVWriter,
PandasParquetReader,
PandasParquetWriter,
PandasPickleReader,
Expand Down
12 changes: 6 additions & 6 deletions tests/plugins/test_pandas_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from sqlalchemy import create_engine

from hamilton.plugins.pandas_extensions import (
PandasCsvReader,
PandasCsvWriter,
PandasCSVReader,
PandasCSVWriter,
PandasFeatherReader,
PandasFeatherWriter,
PandasHtmlReader,
Expand Down Expand Up @@ -188,19 +188,19 @@ def test_pandas_feather_writer(tmp_path: pathlib.Path) -> None:

def test_pandas_csv_reader(tmp_path: pathlib.Path) -> None:
path_to_test = "tests/resources/data/test_load_from_data.csv"
reader = PandasCsvReader(path=path_to_test)
reader = PandasCSVReader(path=path_to_test)
df, metadata = reader.load_data(pd.DataFrame)

assert PandasCsvReader.applicable_types() == [pd.DataFrame]
assert PandasCSVReader.applicable_types() == [pd.DataFrame]
assert df.loc[0, "firstName"] == "John"
assert df.shape == (3, 5)


def test_pandas_csv_writer(tmp_path: pathlib.Path) -> None:
file_path = tmp_path / "test.csv"
writer = PandasCsvWriter(path=file_path)
writer = PandasCSVWriter(path=file_path)
metadata = writer.save_data(pd.DataFrame(data={"col1": [1, 2], "col2": [4, 3]}))

assert PandasCsvWriter.applicable_types() == [pd.DataFrame]
assert PandasCSVWriter.applicable_types() == [pd.DataFrame]
assert file_path.exists()
assert metadata["path"] == file_path

0 comments on commit 16bb3bc

Please sign in to comment.