by Suf | Apr 16, 2022 | Programming, Python, Tips
If you try to import a JSON file containing endline separators \n into a pandas DataFrame, you will encounter ValueError: Trailing data. To solve this error, you can set the lines parameter in read_json to True, ensuring that each line reads as a JSON object. For...
by Suf | Apr 16, 2022 | Programming, Python, Tips
If you try to join together two DataFrames that share one or more column names but do not provide a suffix for either the right or left DataFrame to differentiate the between the columns, you will raise the ValueError: Columns overlap but no suffix specified. To solve...
by Suf | Apr 15, 2022 | Pandas, Programming, Python, Tips
If you want to plot a scatter matrix using Pandas, you have to call scatter_matrix from the pandas.plotting module. If you try to call scatter_matrix from pandas, you will raise the AttributeError: module ‘pandas’ has no attribute...
by Suf | Apr 15, 2022 | Programming, Python, Tips
In Python 3, File object does not support the next() method. Instead, Python 3 has a built-in function next, which retrieves the next item from the iterator by invoking its __next__() method. If you try to call next() on a reader object in Python 3, you will raise the...
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...