Drop a specific row in Pandas

df = pd.DataFrame([[‘Jhon’,15,’A’],[‘Anna’,19,’B’],[‘Paul’,25,’D’]]) df. columns = [‘Name’,’Age’,’Grade’] df Out[472]: Name Age Grade 0 Jhon 15 A 1 Anna 19 B 2 Paul 25 D You can get the index of your row: i = df[((df.Name == ‘jhon’) &( df.Age == 15) & (df.Grade == ‘A’))].index and then drop it: df.drop(i) Out[474]: Name Age Grade 1 … Read more

AttributeError: module ‘pkgutil’ has no attribute ‘ImpImporter’. Did you mean: ‘zipimporter’?

If you can downgrade to Python 3.11 then you will probably not face any issue. If you must use only Python 3.12, then here is an attempt to solve the issue: AttributeError: module ‘pkgutil’ has no attribute ‘ImpImporter’. Did you mean: ‘zipimporter’? occurs due to using Python 3.12. Due to the removal of the long-deprecated … Read more

In Python 3, why do I get “TypeError: ‘zip’ object is not subscriptable” (or see a strange result instead of a list)?

In Python 2, zip returned a list. In Python 3, zip returns an iterable object. But you can make it into a list just by calling list, as in: list(zip(…)) In this case, that would be: list(zip(*ngram)) With a list, you can use indexing: items = list(zip(*ngram)) … items[0] etc. But if you only need … Read more

How to Import python package from another directory?

You can add the parent directory to PYTHONPATH, in order to achieve that, you can use OS depending path in the “module search path” which is listed in sys.path. So you can easily add the parent directory like following: import sys sys.path.insert(0, ‘..’) from instance import config Note that the previous code uses a relative … Read more

Specific type annotation for NumPy ndarray using mypy

What you are looking for is the numpy.typing.NDArray class: https://numpy.org/doc/stable/reference/typing.html#numpy.typing.NDArray numpy.typing.NDArray[A] is an alias for numpy.ndarray[Any, numpy.dtype[A]]: import numpy as np import numpy.typing as npt a: npt.NDArray[np.complex64] = np.zeros((3, 3), dtype=np.complex64) # reveal_type(a) # -> numpy.ndarray[Any, numpy.dtype[numpy.complexfloating[numpy.typing._32Bit, numpy.typing._32Bit]]] print(a) prints [[0.+0.j 0.+0.j 0.+0.j] [0.+0.j 0.+0.j 0.+0.j] [0.+0.j 0.+0.j 0.+0.j]] Note that even though you annotate … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)