I am running a python code that produces some figures with Matplotlib and Pandas. After a few runs of the code, I am getting to following error: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (matplotlib.pyplot.figure) are retained until explicitly closed a…
Tag: python
Python subprocess returning exception
I have the following code that has been working until recently: it calls the opt_module_v3.py and returns messages as the child process runs. When I run the main code, I’m getting the following exception: Like I mentioned, this code was working before but I might have stuffed up since I’ve been wo…
Python Requests InvalidURL: Failed to parse URL
thanks you very much. it has a “u200b” follow the .com. “u200b” is an invisable character. the reason is i copy the url from the website. but something interesting i found: if i use pip install requests==2.21.0(old version), it will not except this err. only use new version it will err…
Pandas: Check each row for condition and insert row below if condition is met
this is my first question here as I really couldn’t figure it out with related answers: I have a list of dataframes “df_list”, for each user I have a dataframe which basically looks like: Data: I would like to go through all the dataframes in my df_list and inside each df I would like to add…
pyspark create all possible combinations of column values of a dataframe
I want to get all the possible combinations of size 2 of a column in pyspark dataframe. My pyspark dataframe looks like One way would be to collect the values and get them into python iterable (list, pandas df) and use itertools.combinations to generate all combinations. However, I want to avoid collecting th…
Logical with count in Pyspark
I’m new to Pyspark and I have a problem to solve. I have a dataframe with 4 columns, being customers, person, is_online_store and count: customer PersonId is_online_store count afabd2d2 4 true 1 afabd2d2 8 true 2 afabd2d2 3 true 1 afabd2d2 2 false 1 afabd2d2 4 false 1 I need to create according to the f…
Using spacy to redact names from a column in a data frame
I have a data frame named “df1”. This data frame has 12 columns. The last column in this data frame is called notes. I need to replace common names like “john, sally and richard” from this column and replace the values with xxxx or something similar. I have a working script that is cre…
Calculate difference between date column entries and date minimum Pyspark
I feel like this is a stupid question, but I cannot seem to figure it out, so here goes. I have a PySpark data frame and one of the columns consists of dates. I want to compute the difference between each date in this column and the minimum date in the column, for the purpose of filtering to the past
How to change the number of size categories in seaborn scatterplot
I tried hard to look through all the documentation and examples but I am not able to figure it out. How do I change the number of categories = the number of size bubbles, and their boundaries in seaborn scatterplot? The sizes parameter doesn’t help here. It always gives me 6 of them regardless of what I…
Send query params from Jinja template
I can’t figure out if it’s possible to pass query parameters from a static html page to a view for processing. I have now implemented the functionality I need using path parameters. I want to do the same, but with query parameters main.py events.py routes.py html It’s works with “POST …