I have a lot of excel files that I need to compile into a single excel file, and then copy the compiled one into an existing excel file (with macro / .xlsm) in a certain sheet. I solved the first problem (compiling multiple excel files into a single excel file). The resulted dataframe is saved in .csv format.…
Python showing an OpenCV Assertion error for finding contours
I was trying to draw contours in an image using Python OpenCV. My code is the following: I am getting an error while compiling this code. The error is the following: How can I avoid this error? Answer The problem should be that cv2.drawContours (and in general all opencv “drawing” functions in pyt…
raise NeedDownloadError(‘Need ffmpeg exe. ‘ NeedDownloadError: Need ffmpeg exe)
I’m trying to execute a call to an unofficial Instagram API python library, after several errors for dependencies needed I fixed, I’m stuck at this one. Answer This package relies on the ffmpeg executable to be in the PATH. So just download it, install it somewhere, and add installation directory …
Django: Related model ‘users.UserProfile’ cannot be resolved
I tried running makemigrations and after migrate and I am constantly getting this error: What I was trying to do is Link a UserProfile model to Django’s own User Model: The “Contests” model (as you can see in my installed apps below) uses the User Model as well without any errors. My Install…
Is there a way to set up start viewing position in excel sheet?
Normally Excel remembers where you stopped at a sheet and when you open it next time it takes you right there. Is there a way to set up such a position when generating the document? Answer With the pywin32 package, you can control Excel with COM and automate anything that Excel can do. Here’s an example…
bisect_left on first item of list within list, Python 3
I have a list like this for example: and I need to = bisect_left the first item of each tuple to find an index in the list. However, I can’t think of a way of doing this without creating a list of all of these first items before hand: exampleList = [L[i][0] for i in range(len(L))] any ideas on another
Python asyncio task list generation without executing the function
While working in asyncio, I’m trying to use a list comprehension to build my task list. The basic form of the function is as follows: My goal is to use a list of terms to create my task list: My initial thought was: This doesn’t create the task list it runs the function during the list comprehensi…
How to insert javascript code into Jupyter
I’m trying to insert this script on custom.js. I changes to color red all the negative currency. I want it to be applied to all pandas dataframes printed on Jupyter. After adding it to all custom.js available on jupyter/anaconda folders, it still didn’t change anything. Can someone help me? Answer
How to store the result from %%timeit cell magic?
I can’t figure out how to store the result from cell magic – %%timeit? I’ve read: Can you capture the output of ipython’s magic methods? Capture the result of an IPython magic function and in this questions answers only about line magic. In line mode (%) this works: But in cell mode (%…
sklearn Clustering: Fastest way to determine optimal number of cluster on large data sets
I use KMeans and the silhouette_score from sklearn in python to calculate my cluster, but on >10.000 samples with >1000 cluster calculating the silhouette_score is very slow. Is there a faster method to determine the optimal number of cluster? Or should I change the clustering algorithm? If yes, which i…