I am currently trying to plot a few maps by using Plotly Express and Mapbox in Python. I need to have a big map with the country and, next to it, an inset map with a “zoom” to a particular region (see Image attached as an example) INSET MAP EXAMPLE. I managed to plot the bigger map (i.e. the whole
yfinance not working – receiving json.decoder.JSONDecodeError
I am scraping stock market data from yfinance. My code worked perfectly during the last weeks. For some reason, now I am receiving the following error: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) when executing: I have read about this error on Stack Overflow, but no one had an appr…
How to get the label values on a bar chat with seaborn on a categorical data
Shown below is the syntax used to get the bar char for a categorical data on seaborn How can I get the value count on the bar chart shown below. How to get the percentage value on the bar chart shown below. Answer Maybe this will work for you: Results:
Why does a function in a class does not return anything?
For exercising reasons, I am trying to implement a class SSM which stands for Static Sorted Map in python in order to implement the methods min_value(self) : find the minimum value max_value(self) : find the maximum value search(self, key): to find an element in the list The list is assumed to be sorted. Here…
My Python Caeser Cipher program stops shifting after 30
I created a function to split inputed string into list of words and then replace the letters in each word with its shifted counterpart but when I set the shift to over 30 it prints unchanged. Answer One useful trick here is to use the modulus operator (%). It will take care of the shift for you. Here is how
How to get a count of specific element in nested list python
so I want to get the count of ‘expert’ and ‘user’ from every row of data frame and from every list. And after getting a count of experts and users, I want to store the respective ids in another list. I have tried converting them into the dictionary and calculate using key but it is not…
Why am I getting error after looping into file and trying to join the list
I have large text file which has numbers. I want to loop through the file and append the numbers to the list_of_numbers. Problem is that the loop appends to the list but not in the way I want, that’s why the list looks like this after iteration this is just part of the output. I want this to be in
Elegant way to write np.where for different values in a column
I have a dataframe like as shown below I would like to apply 2 rules to the logout_date column Rule 1 – If person type is B, C,D,E AND logout_date is NaN, then copy the login date value Rule 2 – If person type is A AND logout_date is NaN, then add 2 days to the login date I tried
How to save Farsi text in csv file using python?
I was trying to save my dataset in a CSV file with the following script: but the result is confusing, write some unknown chars to CSV file instead of Farsi chars: Can anyone help me? I want to write all these files in a CSV: example of what I have in one of them and want to write: but result:
Sns Scatter plot with differet color coding and different markers
I would like to create a Seaborn scatter-plot, using the following dataframe: In my graph A should be the x-variable and B the y-variable. Furthermore I would like to color based on column D. Finally, when C=’y’ the marker should be open-faced (no facecolor) and when C=’n’ the marker s…