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

Suppress pandas FutureWarnings #165

Merged
merged 12 commits into from
Dec 2, 2024
4 changes: 2 additions & 2 deletions bcpandas/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ class BCPandasValueError(BCPandasException):

def get_delimiter(df: pd.DataFrame) -> str:
for delim in _DELIMITER_OPTIONS:
if not df.applymap(lambda x: delim in x if isinstance(x, str) else False).any().any():
if not df.map(lambda x: delim in x if isinstance(x, str) else False).any().any():
return delim
raise BCPandasValueError(error_msg.format(typ="delimiter", opts=_DELIMITER_OPTIONS))


def get_quotechar(df: pd.DataFrame) -> str:
for qc in _QUOTECHAR_OPTIONS:
if not df.applymap(lambda x: qc in x if isinstance(x, str) else False).any().any():
if not df.map(lambda x: qc in x if isinstance(x, str) else False).any().any():
return qc
raise BCPandasValueError(error_msg.format(typ="quote", opts=_QUOTECHAR_OPTIONS))
4 changes: 2 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@

def not_has_all_delims(df: pd.DataFrame) -> bool:
return not all(
df.applymap(lambda x: delim in x if isinstance(x, str) else False).any().any()
df.map(lambda x: delim in x if isinstance(x, str) else False).any().any()
for delim in _DELIMITER_OPTIONS
)


def not_has_all_quotechars(df: pd.DataFrame) -> bool:
return not all(
df.applymap(lambda x: qc in x if isinstance(x, str) else False).any().any()
df.map(lambda x: qc in x if isinstance(x, str) else False).any().any()
for qc in _QUOTECHAR_OPTIONS
)

Expand Down