I just started a python bootcamp and am using Microsoft Visual Studio Code (latest version with Python 3.10.5) but have a couple of questions. (apologies for the long post) I have the following code: To my knowledge there are three options to run the code Right mouse click and ‘run python file in termin…
Tag: python
Scale/resize a square matrix into a larger size whilst retaining the grid structure/pattern (Python)
Like above, I want to retain the same ‘grid’ format whilst increasing the dimensions of the 2D array. How would I go about doing this? I assume the original matrix can only be scaled up by an integer n. Answer You can use numba if performance is of importance (similar post) with no python jitting …
Visualize how multiple categorical values differ across rows and columns in a dataframe
I have the following DataFrame where each column represents a categorization algorithm for the items in the index (a,b, …) I would like to reorder the category names in each column so that I can better assess whether the index items are being categorised similarly across columns. Is there a way to visualise h…
Find value smaller but closest to current value
I have a very large pandas dataframe that contains two columns, column A and column B. For each value in column A, I would like to find the largest value in column B that is less than the corresponding value in column A. Note that each value in column B can be mapped to many values in column A. Here’s
How to open multiple sites in Selenium with user input?
I’m fairly new to coding with Python and I had some questions regarding Selenium: So basically what I’m trying is: -user inputs multiple links to different sites -the script opens the first link and closes the browser afterwards and opens the next link -the user only inputs for example ‘goog…
Dask Distributed: Reducing Multiple Dimensions into a Distance Matrix
I want to calculate a large distance matrix, based on a higher dimensional vector. For instance, I have 1000 instances each represented by 20 vectors of length 10. The distance between each two instances is given by the mean distance between each of the 20 vectors associated to each vector. So I want to go fr…
Algorithm verification: Get all the combinaison of possible word
I wanted to know if the algorithm that i wrotte just below in python is correct. My goal is to find an algorithm that print/find all the possible combinaison of words that can be done using the character from character ‘!’ (decimal value = 33) to character ‘~’ (decimal value = 126) in …
Saving related model objects in single view
I am beginner and I am working on Django project – risk assessment application. I have a trouble to achieve saving on related objects for my application risk record. I am using MultiModelForm to achieve the following. I am successfully creating Whatif instance and connecting it with GuideWordi instance …
Load python notebook [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 8 months ago. Improve this question I would like to load a text in python notebook that is undirected network. it is does not w…
pandas csv UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x81 in position 162: invalid start byte
I’m trying to read one column from a csv (with header ‘Peptide Sequence’). However, this gives me the error as in the title. I know this probably has something to do with the encoding, which I know very little about. Is there a quick workaround for this? Answer read_csv takes an encoding arg…