Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ add pandas.Series #68

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
89a2c38
Add support and test for pd.Series
EkberHasanov Jun 25, 2023
b726b19
Adding docs for basic usage
EkberHasanov Jun 25, 2023
24bf87a
Fix documentation
EkberHasanov Jun 25, 2023
1bb8a71
Add pandas to optional dependencies
EkberHasanov Jun 25, 2023
bc37f7f
fix python3.8 issues
EkberHasanov Jun 26, 2023
43be7f6
fix py3.7 issues
EkberHasanov Jun 26, 2023
50b0547
fix macos error
EkberHasanov Jun 27, 2023
16aa656
fix indentation error in ci.yml
EkberHasanov Jun 27, 2023
0d899c9
ci: fix dependency issue in macos
EkberHasanov Jun 30, 2023
33f45f2
improve test coverage to 100%
EkberHasanov Jun 30, 2023
98e58d6
🔧 update code
yezz123 Jun 30, 2023
b4a35ac
🍱 update requirements
yezz123 Jun 30, 2023
1660ca7
Merge branch 'main' into type/pandas
yezz123 Jun 30, 2023
b1e04f0
🍱 Fix Requirements
yezz123 Jun 30, 2023
2ac57cd
🍱 Fix Requirements
yezz123 Jun 30, 2023
339c71b
.
yezz123 Jun 30, 2023
7129b91
fix
yezz123 Jun 30, 2023
c9c4f12
Update pydantic_extra_types/pandas_types.py
yezz123 Jul 1, 2023
cc9dac0
Inheriting directly from pd.Series
EkberHasanov Jul 6, 2023
501c173
Merge branch 'main' into type/pandas
EkberHasanov Jul 6, 2023
09e073d
delete extra files
EkberHasanov Jul 12, 2023
b15b3d0
upgrading version of pandas
EkberHasanov Feb 25, 2024
2718471
Merge branch 'main' into type/pandas
EkberHasanov Feb 25, 2024
8e408bc
Update pyproject.txt
EkberHasanov Feb 25, 2024
7b4433f
Update test_json_schema.py
EkberHasanov Feb 25, 2024
6cff2d7
Update linting.in
EkberHasanov Feb 25, 2024
3d7b805
adding pandas-stubs
EkberHasanov Feb 25, 2024
b751633
fix versions
EkberHasanov Feb 25, 2024
d78fc5a
resolve version issue
EkberHasanov Feb 25, 2024
6a55cd2
upgrading version of numpy
EkberHasanov Feb 25, 2024
ba7a941
fixing some issues
EkberHasanov Feb 25, 2024
933540a
change core_schema func
EkberHasanov Feb 29, 2024
25da211
Merge branch 'main' into type/pandas
EkberHasanov Feb 29, 2024
811d664
Update test_json_schema.py
EkberHasanov Feb 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
🔧 update code
  • Loading branch information
yezz123 committed Jun 30, 2023
commit 98e58d6b19345ab51de92070317c945127ab2d4e
10 changes: 8 additions & 2 deletions pydantic_extra_types/pandas_types.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
from typing import Any, List, Tuple, Type, TypeVar, Union

import pandas as pd
from pydantic import GetCoreSchemaHandler
from pydantic_core import core_schema

try:
import pandas as pd
except ModuleNotFoundError: # pragma: no cover
raise RuntimeError(
'`PhoneNumber` requires "phonenumbers" to be installed. You can install it with "pip install phonenumbers"'
)

T = TypeVar('T', str, bytes, bool, int, float, complex, pd.Timestamp, pd.Timedelta, pd.Period)


Expand Down Expand Up @@ -33,7 +39,7 @@ def __getattr__(self, name: str) -> Any:
return getattr(self.value, name)

def __eq__(self, __value: object) -> bool:
return isinstance(__value, pd.Series) or isinstance(__value, Series)
return isinstance(__value, (pd.Series, Series))

def __add__(self, other: Union['Series', List[Any], Tuple[Any], T]) -> 'Series':
if isinstance(other, Series):
Expand Down
10 changes: 10 additions & 0 deletions tests/test_json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
CountryOfficialName,
CountryShortName,
)
from pydantic_extra_types.pandas_types import Series
from pydantic_extra_types.payment import PaymentCardNumber


Expand Down Expand Up @@ -85,6 +86,15 @@
'type': 'object',
},
),
(
Series,
{
'properties': {'x': {'title': 'X'}},
'required': ['x'],
'title': 'Model',
'type': 'object',
},
),
],
)
def test_json_schema(cls, expected):
Expand Down