so I have a Regex expression that I’m matching against a single string provided to check and match certain information. If it’s matched, only the captured group is returned. I have made my function so that it removes any null strings from the returned array and finally, just gives the captured str…
Multiple context menu in a single qTableView pyqt5
i added two functions in two different pushButtons. for both function i used a common qtableView. i created two contextmenu, whenever user clicked pushButton1 func1 is called and result set will be shown in qtableView and user can select items from contextmenu1 and same like pushButton2 ,where contextMenu2 wi…
Pandas conditional counting by date
I want to count all orders done by each customer at each order date, to find out how many orders were done at the time of each order. Input: Expected output: The following code works but is extremely slow. Taking upwards of 10 hours for 100k+ rows. There is certainly a better way. Answer Try sort_values to ge…
Start a Thread Timer directly
I want to trigger the self._runSequence() func directly after start the timer. This is my code: If sequenceDuration is equal to 10 the func will be called 10 seconds later (as a normal timer I know..) This is the RepeatedTimer Class: What I already try: But this give me an error when the timer trigger the __r…
comparing numpy arrays with tolerance
I’m trying to compare floating numbers that are stored in numpy arrays. I would like them to be compared with a tolerance and every number of the array should be compared with every number of the other array. My attempt is shown underneath, I used two simple arrays as examples but it has the problem tha…
Using Geopandas on python to create an interactive map
I’m trying to create an interactive map using this guide: This I use pycharm with anaconda environment, so I don’t understand when put my .shp file. This is the example code: Is this correct my directory? Error: Thank you in advance. Giovanni Answer You seem to have a n in your path, which is inte…
How to covert a list into a list with sublists? python
I’m making a little data base on python. I want to convert the list into this Is there anyway i can do this? Answer zip will return a tuple from two iterables; if you take the same list, but shifted as you wish (in this case, one element forward) you can have your expected result. Also, the generator wi…
python string concatenation following a sequence
What would be the most pythonic way of creating the following string concatenation: We have an initial dataframe with some of the columns being: origin dest_1_country dest_1_city dest_2_country dest_2_city dest_3_country dest_3_city dest_4_country dest_4_city We want to create an additional column that is the…
IndexError: list index out of range error on python
This is my code: This is in items.txt: I am getting this error: I am trying to make a program that makes a receipt of items so if you could provide any code that would be helpful. Any help would be appreciated. Answer The problem you have in your code is with the empty strings in your items.txt file. When
pyspark – filter rows containing set of special characters
I have a data frame as follow:- Now I want to find the count of total special characters present in each column. So I have used str. contains function to find it, though it is running but it does not find the special characters. Answer You may want to use rlike instead of contains, which allows to search for …