diff --git a/docarray/array/doc_list/io.py b/docarray/array/doc_list/io.py index 40d3486699f..c84e3a92b77 100644 --- a/docarray/array/doc_list/io.py +++ b/docarray/array/doc_list/io.py @@ -426,7 +426,7 @@ def to_csv( writer.writerow(doc_dict) @classmethod - def from_pandas(cls, df: 'pd.DataFrame') -> 'DocList': + def from_dataframe(cls, df: 'pd.DataFrame') -> 'DocList': """ Load a DocList from a `pandas.DataFrame` following the schema defined in the :attr:`~docarray.DocList.doc_type` attribute. @@ -456,7 +456,7 @@ class Person(BaseDoc): data=[['Maria', 12345], ['Jake', 54321]], columns=['name', 'follower'] ) - docs = DocList[Person].from_pandas(df) + docs = DocList[Person].from_dataframe(df) assert docs.name == ['Maria', 'Jake'] assert docs.follower == [12345, 54321] @@ -499,7 +499,7 @@ class Person(BaseDoc): return docs - def to_pandas(self) -> 'pd.DataFrame': + def to_dataframe(self) -> 'pd.DataFrame': """ Save a DocList to a `pandas.DataFrame`. The field names will be stored as column names. Each row of the dataframe corresponds diff --git a/tests/units/array/test_array_from_to_pandas.py b/tests/units/array/test_array_from_to_pandas.py index 2f95f4f66aa..d8c30c4ee39 100644 --- a/tests/units/array/test_array_from_to_pandas.py +++ b/tests/units/array/test_array_from_to_pandas.py @@ -30,7 +30,7 @@ def test_to_from_pandas_df(nested_doc_cls): nested_doc_cls(text='hello world', image=ImageDoc()), ] ) - df = da.to_pandas() + df = da.to_dataframe() assert isinstance(df, pd.DataFrame) assert len(df) == 2 assert ( @@ -47,7 +47,7 @@ def test_to_from_pandas_df(nested_doc_cls): ] ).all() - da_from_df = DocList[nested_doc_cls].from_pandas(df) + da_from_df = DocList[nested_doc_cls].from_dataframe(df) for doc1, doc2 in zip(da, da_from_df): assert doc1 == doc2 @@ -76,7 +76,7 @@ def test_from_pandas_without_schema_raise_exception(): df = pd.DataFrame( columns=['title', 'count'], data=[['title 0', 0], ['title 1', 1]] ) - DocList.from_pandas(df=df) + DocList.from_dataframe(df=df) def test_from_pandas_with_wrong_schema_raise_exception(nested_doc): @@ -84,4 +84,4 @@ def test_from_pandas_with_wrong_schema_raise_exception(nested_doc): df = pd.DataFrame( columns=['title', 'count'], data=[['title 0', 0], ['title 1', 1]] ) - DocList[nested_doc.__class__].from_pandas(df=df) + DocList[nested_doc.__class__].from_dataframe(df=df)