I need to replace part of the string value with extra zeroes if it needs. T-46-5-В,Г,6-В,Г —> T-46-005-В,Г,006-В,Г or T-46-55-В,Г,56-В,Г —> T-46-055-В,Г,066-В,Г, for example. I have Regex pattern ^D-d{1,2}-([d,]+)-[а-яА-я,]+,([d,]+)-[а-яА-я,]+$ that retrieves 2 separate groups of the string,…
How to merge rows in a Dataframe based on a previous row?
I have a sequentially ordered dataframe that represent two events measured over time – the measurements are the start and end times of the event. They should be ordered in an ABABAB sequence, but in some cases I may have consecutive events of the same type (i.e. ABABAABABB). I am looking for a way to ch…
Listing each iteration of rolling a six-sided-die in Python
I’m working on an animated bar plot to show how the number frequencies of rolling a six-sided die converge the more you roll the die. I’d like to show the number frequencies after each iteration, and for that I have to get a list of the number frequencies for that iteration in another list. Here&#…
Collatz’s hypothesis testing in Python
I am trying to build a small program to test the collatz’s hypothesis. So far, I have the following: But when I run it, it’s going into an endless loop of 0.0s. Not really getting where the problem is. Answer As Nearoo mentioned, c0 % 2 is the same as c0 % 2 != 0 because 1 (when c0 is
How to create a new line when only using n with variables rather than printed text?
I am using Python for reference. I am trying to create a new line when displaying name, address, city, state, and zip code. However, when I do this, IDLE tells me that “unexpected character after line continuation character”. My code is as follows: I know that I can print each thing separately but…
How can I fix function object is not iterable?
After calling both functions I’m getting ‘function object is not itrable’ as an error. I’m thinking the error appears somewhere in the for loop, I just can’t figure out why if I’m iterating through a list. The purpose of the program is to output the range of numbers between…
Trying to convert input to list
I’m trying to take input from user for 2 points and output the distance. I’m getting stuck on converting the input to a list for the output. I might be thinking about it the wrong way, any help to get me in the right direction is appreciated. Answer You can use a list comprehension to translate th…
Group by 2 columns with calculation of quantile of 3rd numerical column
I have a df below as: I have code below that calculates the % of each mealtype for each day How can I tweak this code to give me the quantiles – p50 and p90 of the oz column, but grouped by mealtype day and mealtype as well? Thanks! Answer You can try this or output
How to get all tr id by using python selenium?
i have try but not work. Cannot get all id of tr AAAA, BBBB, CCCC. Thanks Answer I prefer to use xpath to do the all things:
How to use pd.data_range() with a frequency of X minutes/hours/seconds?
I need to create a frequent date range with pandas date_range(). This works well with frequency=… parameter. But sometimes my code needs these frequent ranges in longer frequencys. for example 4 Hours or 5 minutes instead of one. How can I do that with pd.date_range(first_X_datetime, last_X_datetime, fr…