Skip to content
Advertisement

Tag: python

How to fix a Mac base conda environment when sqlite3 is broken

I recently updated the Python version of my base conda environment from 3.8 to 3.9, using mamba update python=3.9, but I can no longer run IPython, because the sqlite3 package appears to be broken. Since I had another Python 3.9 environment that is still functional, I tried copying over the envs/py39/lib/sqlite3.36.0 and envs/py39/lib/python3.9/sqlite3 directories, as well as envs/py39/lib/python3.9/lib-dynload/_sqlite3.cpython-39-darwin.so because I

Replacing String Text That Contains Double Quotes

I have a number series contained in a string, and I want to remove everything but the number series. But the double quotes are giving me errors. Here are examples of the strings and a sample command that I have used. All I want is 127.60-02-15, 127.60-02-16, etc. I have tried all sorts of methods (e.g., triple double quotes, single

how to delete the entire line if line has specific word in python

i have a .txt file like this: and i want to delete the entire line that include “pen” word like this: and i tried this —————————AND—————————— how i delete just the “pen” word in the .txt file Answer First you need to put the result on another file (myfile2) and you need to print on this file the lines thats

Transform a 3D numpy array to 1D based on column value

Maybe this is a very simple task, but I have a numpy.ndarray with shape (1988,3). I want to create a 1D array with shape=(1988,) that will have values corresponding to the column of my 3D array that has a value of 1. For example, How can I do this? Answer You can use numpy.nonzero: Output: array([0, 1, 2, 1, 0,

Advertisement