warnings

Python3.12 SyntaxWarning on triplequoted string `d` must be `\d`

Python3.12 SyntaxWarning on triplequoted string `d` must be `\d` Question: After updating to Python 3.12, I get warnings about invalid escape sequence on some triple-quotes comments. Is this a new restriction? I have the habit of documenting code using triple-quoted string, but this has never been a problem prior to Python 3.12. python3 –version Python …

Total answers: 1

How to correct this code to not raise a SettingWithCopyWarning?

How to correct this code to not raise a SettingWithCopyWarning? Question: I’m following along with this: https://www.kdnuggets.com/2021/01/cleaner-data-analysis-pandas-pipes.html About halfway down the author creates a function to remove outliers: def to_category(df): cols = df.select_dtypes(include=’object’).columns for col in cols: ratio = len(df[col].value_counts()) / len(df) if ratio < 0.05: df[col] = df[col].astype(‘category’) return df This raised a warning …

Total answers: 1

SettingWithCopyWarning in Pandas 1.5.3 not working

SettingWithCopyWarning in Pandas 1.5.3 not working Question: I’m aware there are a few threads about this but I’m having trouble with the actual SettingWithCopyWarning itself so none of them are of any help. I’ve recently nuked my machine and am in the process of reinstalling Pycharm and all the libraries etc. On running some of …

Total answers: 1

What to do about future warning when using sklearn.neighbors?

What to do about future warning when using sklearn.neighbors? Question: I fear, I have the same problem as in this post: getting a warning when using sklearn.neighbors about keepdims I try to use KNN as part of an ensemble classifier, but everytime I get the following warning: FutureWarning: Unlike other reduction functions (e.g. skew, kurtosis), …

Total answers: 2

Avoid formatting issues when warnings.captureWarnings(True) is set

Avoid formatting issues when warnings.captureWarnings(True) is set Question: I have created a log handler which logs to a database table, and I wanted to also capture warnings issued by the program into a different table, so used warnings.captureWarnings(True) I had some issues with the message formatting in the py.warnings logger – the message always showed …

Total answers: 1

python -We ResourceWarning not erroring

python -We ResourceWarning not erroring Question: If I take a simple test script like this, which results in ResourceWarning: import asyncio import aiohttp async def main(): client = aiohttp.ClientSession() await client.get("https://google.com") asyncio.run(main()) Run it with python -bb -We -X dev test.py. I’m expecting the ResourceWarning to error and result in a non-0 exit code. Actual …

Total answers: 1

FutureWarning: save is not part of the public API in Python

FutureWarning: save is not part of the public API in Python Question: I am using Python to convert Pandas df to .xlsx (in Plotly-Dash app.). All working well so far but with this warning tho: "FutureWarning: save is not part of the public API, usage can give unexpected results and will be removed in a …

Total answers: 1

Warning messages from scapy

Warning messages from scapy Question: Using this: from scapy.all import * I’ve got these two warnings which I want to remove Warning (from warnings module): File "C:UserslocalfpAppDataLocalProgramsPythonPython310libsite-packagesscapylayersipsec.py", line 471 cipher=algorithms.Blowfish, CryptographyDeprecationWarning: Blowfish has been deprecated Warning (from warnings module): File "C:UserslocalfpAppDataLocalProgramsPythonPython310libsite-packagesscapylayersipsec.py", line 485 cipher=algorithms.CAST5, CryptographyDeprecationWarning: CAST5 has been deprecated Unfortunately I’ve found the solution for …

Total answers: 3