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

Update library to support python 3.12 and pandas>=2.0 #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion pandas_schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def validate(self, df: pd.DataFrame, columns: typing.List[str] = None) -> typing
# We associate the column objects in the schema with data frame series either by name or by position, depending
# on the value of self.ordered
if self.ordered:
series = [x[1] for x in df.iteritems()]
series = [df.iloc[:, i] for i in range(len(df.columns))]
column_pairs = zip(series, self.columns)
else:
column_pairs = []
Expand Down
4 changes: 2 additions & 2 deletions pandas_schema/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def default_message(self):
return 'contains trailing whitespace'

def validate(self, series: pd.Series) -> pd.Series:
return ~series.astype(str).str.contains('\s+$')
return ~series.astype(str).str.contains(r'\s+$')


class LeadingWhitespaceValidation(_SeriesValidation):
Expand All @@ -345,7 +345,7 @@ def default_message(self):
return 'contains leading whitespace'

def validate(self, series: pd.Series) -> pd.Series:
return ~series.astype(str).str.contains('^\s+')
return ~series.astype(str).str.contains(r'^\s+')


class IsDistinctValidation(_SeriesValidation):
Expand Down
2 changes: 1 addition & 1 deletion pandas_schema/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.3.6'
__version__ = '0.3.7'
4 changes: 2 additions & 2 deletions test/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def test_invalid_dates(self):

class StringRegexMatch(ValidationTestBase):
def setUp(self):
self.validator = MatchesPatternValidation('^.+\.txt$')
self.validator = MatchesPatternValidation(r'^.+\.txt$')

def test_valid_strings(self):
self.validate_and_compare(
Expand Down Expand Up @@ -408,7 +408,7 @@ class CompiledRegexMatch(ValidationTestBase):
"""

def setUp(self):
self.validator = MatchesPatternValidation(re.compile('^.+\.txt$', re.IGNORECASE))
self.validator = MatchesPatternValidation(re.compile(r'^.+\.txt$', re.IGNORECASE))

def test_valid_strings(self):
self.validate_and_compare(
Expand Down