I have two dataframes: df1: df2 I want to write a function that checks if the column headers are matching/the same as columns in df1. IF not we get a message telling us what column is missing. Example of the message given these dataframes: I want a generalized code that can work for any given dataframe. Is th…
How to overload a function with default parameters in Python
So I have the following (simplified) code which I don’t know how to get to typecheck. If I don’t add the overloads mypy complains that I might be indexing into a tuple with a str index. The as_tuple parameter defaults to false, so mypy should be able to infer that I’m using the first overloa…
pyinstaller makes an empty black window of my tkinter gui
For a very simple example, consider the following code which produces a window like so: After running pyinstaller –onefile –noconsole minimal.py (the name of the code file is minimal.py), I obtain, in the dist folder a bundle file (the app) which, when run, gives me the following: The menu works j…
Trying to detect speech using VAD(Voice Activity Detector)
I am able to read the audio but I am getting an error message while passing it to VAD(Voice Activity Detector). I think the error message is because the frames is in bytes, when feeding it to vad.is_speech(frame, sample_rate), should this frame be in bytes? Here is the code below: Here is the error message: T…
File on Python (os.startfile) can’t be opend
I have a file in which search results (paths) are saved. I only want the very first result to be opend. I did this with: The print result is: O:/111/222/test_99.zip’ But the error is: FileNotFoundError: [WinError 2] system cannot find the file specified: O:/111/222/test_99.zip’ An addition: O: Is …
Python: Reassigning Object to Class with No Constructor Does Not Overwrite Dictionary Field
I’m using Python 3.9.1 and am confused how Python’s default constructor works. I have the below class with a Dictionary field and no Constructor. When I populate its Dictionary and then reassign my object to a new instance, the dictionary retains its existing value (this also happens for List fiel…
Can anyone give me a function to calculate date and time in python ? I m in WINDOWS 10
Please can anyone provide me function for time,date & day in python just like time = time() and time = “##:##:##” # is replaced with current time in my laptop And date = date() and date = “####/##/##” And day = day() and day = “sun/mon/tue/wed/etc” Answer
How find index where the item length less than x in python
for example i have a list which contain: For example, I want to get the index of the item that the length is less than 30. How to do that?Is it possible? Answer you can use enumerate function and list comprehention for this:
Can a class instance return tuple without using attribute?
I’ve got a small problem which in itself isn’t a big deal but is bugging me none the less. Consider the code below. When passing vector as a parameter to pygame.Surface I have to use the ‘t’ attribute to access the tuple stored in ‘size’. Is there a way to have it simply li…
Regex – match until a group of multiple possibilities
I have the following text: You may have that thing NO you dont BUT maybe yes I’m trying to write a regex which can match everything until it finds some specific words, “NO” and “BUT” in this example, and if the string has both of the words, then stop at the first one: You may hav…