From 69d1d2320a6406c303d1a36be577ec98064d6167 Mon Sep 17 00:00:00 2001 From: samsja Date: Tue, 11 Apr 2023 16:39:46 +0200 Subject: [PATCH 1/3] refactor: rename from_pandas to from_dataframe Signed-off-by: samsja --- docarray/array/doc_list/io.py | 2 +- tests/units/array/test_array_from_to_pandas.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docarray/array/doc_list/io.py b/docarray/array/doc_list/io.py index 40d3486699f..cc4b563a964 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. diff --git a/tests/units/array/test_array_from_to_pandas.py b/tests/units/array/test_array_from_to_pandas.py index 2f95f4f66aa..c8bcacd4e29 100644 --- a/tests/units/array/test_array_from_to_pandas.py +++ b/tests/units/array/test_array_from_to_pandas.py @@ -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) From cb521d048b43127831157e21949a3b1530e92da8 Mon Sep 17 00:00:00 2001 From: samsja Date: Tue, 11 Apr 2023 17:05:06 +0200 Subject: [PATCH 2/3] refactor: rename to_pandas to to_dataframe Signed-off-by: samsja --- docarray/array/doc_list/io.py | 2 +- tests/units/array/test_array_from_to_pandas.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docarray/array/doc_list/io.py b/docarray/array/doc_list/io.py index cc4b563a964..e297f60d7e3 100644 --- a/docarray/array/doc_list/io.py +++ b/docarray/array/doc_list/io.py @@ -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 c8bcacd4e29..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 ( From 3370db71aeaf8d951ac6ced8e7194326dc71c151 Mon Sep 17 00:00:00 2001 From: samsja Date: Tue, 11 Apr 2023 17:08:54 +0200 Subject: [PATCH 3/3] refactor: rename to_pandas to to_dataframe Signed-off-by: samsja --- docarray/array/doc_list/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docarray/array/doc_list/io.py b/docarray/array/doc_list/io.py index e297f60d7e3..c84e3a92b77 100644 --- a/docarray/array/doc_list/io.py +++ b/docarray/array/doc_list/io.py @@ -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]