I created a GUI project in pyqt5 that lets us enter a country’s name in the text input field, then we are getting data from the CoVid-19 API for the particular country. I added a feature (button) which give us a possibility to save matplotlib’s plot with statistics from API to my folder called “stats”. Let’s assume that I enter
localhost refused to connect in a databricks notebook calling the google api
I read the Google API documentation pages (Drive API, pyDrive) and created a databricks notebook to connect to the Google drive. I used the sample code in the documentation page as follow: The CRED_PATH includes the credential file path in /dbfs/FileStore/shared_uploads. The script prompts me the URL to authorize the application but immediately after allowing access it redirects to the
Group branches in an XML tree with Python on a common field
I have a list of order details in a CSV, and want to join all items from the lines together on one order. Example date is: I want everything to be listed in an XML with the root as the Order Number, Child as the Line Number and Sub-Children as Item and Price. I want the output to look like:
Don’t have idea why those errors appears
Everything in this code looks right to me, but when i put some numbers that length is different than 2 or put a word, at the end of code an error appear right below “Good bye” How do i fix that? Thank you in advance. Code: Answer Your inputnumber function doesn’t always return two digits (sometimes it returns None). Since
How can I get “START!” to print after the first line of asterisks when I run it, rather than just the changes of direction?
It will print start and stop, but not on the first line? How can I get “START!” to print after the first line of asterisks when I run it, rather than just the changes of direction? Answer How about just adding a print statement before the while loop and initializing indent at 1 instead of 0?
Checking If Position Exists in Nested List
I’m trying to solve a Python coding problem. Given a certain array containing only 1’s and 0’s I must write a program that returns an array following a few rules: Each 1 must be replaced with a 9 Each 0 must be replaced with the amount of 1’s in its immediate surroundings (above, below, left, right) I’m having trouble with
Creating list of dictionaries from a dictionary using list comprehension
I have a dictionary of the format: And I’m trying to create a list of dictionaries that separate the values, i.e., the result should be: Is there a way I can do this with a one-line list comprehension? What I have tried so far: And my code using a normal “for” loop: Answer Here’s a list comprehension + dictionary comprehension
Matplotlib stacked histogram numpy.ndarray error
I am trying to make a stacked histogram using matplotlib by looping through the categories in the dataframe and assigning the bar color based on a dictionary. I get this error on the ax1.hist() call. How should I fix it? AttributeError: ‘numpy.ndarray’ object has no attribute ‘hist’ Reproducible Example Updated effort, still not working This is close, but it is
Python: Expand 2D array to multiple 1D arrays
Consider the followoing example from np.meshgrid docs: In my application, instead of x and y, I’ve 25 variables. To create a grid out of the 25 variables, one way would be: However, the code will look ugly and not modular w.r.t. the number of variables (since each variable is hard-coded). Therefore, I am interested in something like the following: However,
Merge numpy arrays with different dimensions
I have a numpy array with shape (100,9,17,2). I need to transform it to (100,15,17,2) adding zeros in missing cells. I created a zeros(100,6,17,2) but I can’t merge them. Can you help me? Answer Use numpy’s concatenate function. The axis argument is the argument over which you want the dimensions to be added.