I have some classes in different .py files doing REST API calls to a service using a Bearer auth key. Since I don’t want to store the key in every class I would want to know how I should approach this. Where and how should I store the key? How should the classes using this key access it? Answer “B…
Not all parameters were used in the SQL statement Python – MySql
I want to check if the ID exists already but I get this error: Not all parameters were used in the SQL statement Code: Answer The second argument to execute() should be a sequence of values, one for each placeholder token %s in the query. You did pass a sequence, but not in the way you intended. Strings are s…
I don’t get a print result of function when using range
Why can’t I see the result of the function when I use range()? I want to create a range of numbers where each the number will be evaluate in “colla” function. But range doesn’t work with “colla” Answer Your colla() function requires input numbers of 2 and above. Try this: P…
Pyspark: How to flatten nested arrays by merging values in spark
I have 10000 jsons with different ids each has 10000 names. How to flatten nested arrays by merging values by int or str in pyspark? EDIT: I have added column name_10000_xvz to explain better data structure. I have updated Notes, Input df, required output df and input json files as well. Notes: Input datafram…
Delete columns of a nested list with list comprehension
How would I write this for loop as a list comprehention? This is the list: I want to delete row 4 and 5 I did try this but it just gives me a syntax error Any idea how to do that with a list comprehension? Answer You can slice the list upto index 3: If that is what you want.
python packages not being installed on the virtual environment using ubuntu
I have a requirements.txt file which holds all information of my python packages I need for my Flask application. Here is what I did: python3 -m venv venv source venv/bin/activate sudo pip install -r requirements.txt When I tried to check if the packages were installed on the virtual environment using pip lis…
Remove strings and special characters from multiple columns
I want to remove strings and special characters from multiple columns (which contain nan values). I only want the numbers to be present. Below is one of my columns. Any help will be appreciated! Expected outcome: Answer Start by filling NaN values by empty string, then extract the values by regex, then fill t…
Modifying .trainables.syn1neg[i] with previously trained vectors in Gensim word2vec
My issue is the following. In my code I’m modifying the .wv[word] before training but after .build_vocab(), which is fairly straight forward. Just instead of the vectors in there add mine for every word. Where setIntersection is just a set of common words between gensim word2vec and RandomIndexing train…
I get the error :[WinError 2] The system cannot find the file specified:
this code moves all pdf files into a folder called pdf.It moves the first file then get error for moved file: [WinError 2] The system cannot find the file specified: ‘C:UsersfarbodDesktopPrint Form.pdf’ -> ‘C:/Users/farbod/Desktop/pdf/Print Form.pdf’ note: I also used shutil instead…
KivyMD DatePicker save multiple dates
I want that you can add and choose multiple dates. I tried to send a number with the button click button_nr but I don’t know how I can pass it to the on_save function, so that I can change the self.ids.date_label(button_nr).text . If somebody has a better idea how to save multiple dates I’m open f…