I have a nested list that looks something like this: and a flat list that looks something like this: How do I divided each consecutive element in list1 by each consecutive element in list2 (e.g. 42/2, 432/4, 34/2, 242/6) to get an output like this: I have tried doing this: but since list1 is a nested list the…
scrapy/regex get json_object from html
I’m crawling reviews from a website in scrapy python and want to get all the reviews from the following part of the raw html as a dictionary. Getting the window.cj.listings is no problem, but I can’t seem to get the window.cj.app_data out with regex. The following code works for getting the listin…
How to access captured arguments / closure of python instance method objects?
The idea is to implement the Observer pattern in a non leaking / autocleanup fashion. Therefor the instance method objects should be removed when the the associated object is cleaned up by the gc. My original idea was to only store weak references to the instance method objects with a finalizer to call a clea…
Dask distributed.scheduler – ERROR – Couldn’t gather keys
I created a dask cluster using two local machines using I am trying to find best parameters using dask gridsearchcv. I am facing the following error. I hope someone helps in solving this issue. Thanks in advance. Answer I also meet the same issue, and I find it’s likely to be caused by firewall. Suppose…
Sympy multiplies answer changing it and making it wrong
I am trying to find the inverse of a matrix, however, sympy always multiplies the final answer by 4, thereby making the answer wrong. This multiplication also happens when I use the factor function. Here is the matrix I want to change And here is the “wrong” answer it gives The true answer is the …
Can’t fully disable python linting Pylance VSCODE
I’ve been searching online for quite a while now and can’t seem to find a solution for my problem. I installed Pylance (the newest Microsoft interpreter for Python) and can’t seem to disable linting at all. I’ve tried a lot of options but none worked. Here’s a screenshot of how a…
How to retrieve idAdjustedUTC flag value for a TIMESTAMP column in a parquet file?
I have a parquet file with a number of columns of type converted_type (legacy): TIMESTAMP_MICROS. I want to check if the flag isAjustedToUTC is true. I can get it this way: This gives me either true or false as string. Is there another way to retrieve the value of isAdjustedToUTC without using a regex? Answer…
pandas, merge duplicates if row contains wildcard text
I have a dataset of duplicates (ID). Dataset contains both information and emails. I’m trying to concatenate the emails (if row have character @) and then remove the duplicates. My original dataset: What I wish to accomplish: My current code is a modification of Eric Ed Lohmar code and give the followin…
Custom data generator
I have a standard directory structure of train, validation, test, and each contain class subdirectories. I want to use the flow_from_directory API, but all I can find is an ImageDataGenerator, and the files I have are raw numpy arrays (generated with arr.tofile(…)). Is there an easy way to use ImageData…
List ‘none’ data type element replacing using another element with time info
I have a list of dates to be used in a time series. And the list looks like as follow: I want to fill up the missing dates with what they were actually supposed to be. For example, here in the list x, x[2] = ‘2019-07-01’ that represents the month of July, and the previous two elements are type Non…