by Suf | Apr 15, 2022 | Programming, Python, Tips
In NumPy, if you try to multiply two NumPy arrays with different shapes using *, NumPy will attempt to broadcast the smaller array to the size of the larger array. If the dimensions are incompatible for broadcasting, the interpreter will throw the ValueError: operands...
by Suf | Apr 14, 2022 | Programming, Python, Tips
In Python 2, a string is an array of bytes, like bytes in Python 3. To get a Unicode string, you can call string.decode(). However, literal strings are Unicode by default in Python 3, and you do not need to decode them. If you try to decode a string in Python 3, you...
by Suf | Apr 14, 2022 | Programming, Python, Tips
This error can occur if you are trying to import a package not supported by Python 3. In Python 3, ConfigParser has been renamed configparser, so any Python 2 packages using ConfigParser will throw the ModuleNotFoundError. To solve this error, you can use the Python 3...
by Suf | Apr 14, 2022 | Pandas, Programming, Python, Tips
In Pandas 0.18.0 and above, window functions like rolling_mean were refactored into methods on Series/DataFrame objects rather than top-level functions. The function rolling_mean is deprecated in Pandas version 0.18.0 and above. Instead of pd.rolling_mean(dataframe,...
by Suf | Apr 13, 2022 | Pandas, Programming, Python, Tips
DataFrame is an attribute of the pandas module. If you encounter this error, you have either misspelt DataFrame as dataframe, overridden the pandas import with a variable named pandas or pd, or you have a python script in your working directory called pandas.py or...