I have a python script that draws text and shapes using the OpenCV library. The text and shapes look great on my Ubuntu PC (ran in VirtualBox) with 1920×1080 resolution. When I run the exact script on my own Windows 11 system with the same 1920×1080 resolution it looks really vague. This is is the m…
Tag: python
Problems installing lxml on M1 mac
So, I’m having the classic trouble install lxml. Initially I was just pip installing, but when I tried to free up memory using Element.clear() I was getting the following error: I thought this must be because lxml is using the system’s libxml2 which is probably out of date. So I used homebrew to i…
How to use df groupby to return counts on specific values in column across each month
I have a dataframe made up of dummy car purchases across a year which looks like: df = What I’m looking for is to get an aggregated count of each brand of car for each month in 2021, so it would look like this: df = So far I’ve used this code to group by the year, month but I
how to handle big loops in python?
This is more to do with my code as i’m sure i’m doing something wrong all i’m trying to do is call a main function to repeated itself with a recursive number that at some point i’ll reset. here is my code At first the main thread runs fine, but somewhere in the 2500 interval +- it just…
Python – Checking if the data in the files is the same
I have two lists where I have the same number of files. The files in both folders have the same names, for example: and so on. In the test2 folder I have the same named files. How can I compare for each file if the data in both files is the same? So whether: Are you able to advise something?
Save plotly figure interactively (html) whilst preserving LaTeX font
I created a plotly figure using python and I am aware that one can save the interactive figure in html format by using: fig.write_html(“name_of_figure.html”) For the axis labels, as well as the title of the figure, I used LaTeX fonts like this: fig.update_layout(title=r’$text{Some title}_2$&…
Pandas append does not work (dataframe is not getting bigger)
I am currently trying to write a code that is supposed to add mulitple dataframes into one, using the append method. However, with the code I currently use, it seems that only the first dataframe is read. I have tried locating the problem by adding a len(df) to my code and it seems to that the merged datafram…
Multiply two matrices with different dimensions python
Error: ValueError: shapes (3,1) and (3,2) not aligned: 1 (dim 1) != 3 (dim 0) The error occurs because the matrices are different sizes, but how can I multiply two matrices with different size and where the resulting output should be: [-0.78 0.85]? Any help is appreciated! Mathematical question, for better un…
Automatically and continuously copy files of a certain extension created in source folder and not present in output with Python
I have a program that creates .jpegs in a folder and deletes them after a very short time. I’d like to automatically copy those files to another folder as they are created and before they are deleted. I tried using robocopy but couldn’t manage. How can I do this with Python? Answer this script ana…
ttk:Combobox foreground color change doesn’t work properly. What’s wrong?
Attemps to reliably change the text color in a ttk::Combobox fail. It happens for me on Windows 10 with the native theme. The following code creates two comboboxes with their foreground color set to red. Selecting an option in one of them then the other, back and forth, shows that the foreground color alterna…