iteratively calculate ratio of two columns, add values as new columns
I am able to add a new column to df by taking ratio of two existing columns. However having trouble doing this iteratively.
I have a df as below, with columns 'STRIKE','NAME','2015-08-09', '2015-08-10', '2015-08-11' etc. enter image description here
I would like to calculate the ratio of strike and each of the date column for each element, and add them as a new column.
See also questions close to this topic
Sample dataframe using conditions for each row
I'm trying to take samples from a dataframe within a category, above a certain price. Then combine the samples into a string, and assign to the row. I can do it individually, but I want to find a way to apply it to parts of the dataframe.
Selecting the sample individually is possible
df.loc[df['price'] > 20, :].loc[df['catStr'] == 'ME'].sample(n=3)['SKU'] 153 MEMR1055 145 MEMR1048 168 MEMR1064
And joining the result into a string
",".join(df.loc[df['price'] > 20, :].loc[df['catStr'] == 'ME'].sample(n=3)['SKU']) 'MEMR1048,MEMR1057,MEMR1051'
I also tried using groupby, and writing a function using apply, but couldn't get these methods to work.
Instead of 20, I want to use 'price' of each row, and instead of 'ME' use 'catStr' of each row. Is there a way to iterate the dataframe and and take samples for each row?
Edit Expected output - each row to be a different sample based on its price
'price' 'catStr' 'SKU' 'Result' 125.0 IT ITMR1012 ITMR1024,ITMR1012,ITMR1015 130.0 CU CUMR1018 CUMR1009,CUMR1003,CUMR1002 100.0 MX MXMR1007 MXMR1006,MXMR1012,MXMR1016 225.0 ME MEMR1059 MEMR1018,MEMR1022,MEMR1062 125.0 IT ITMR1008 ITMR1022,ITMR1010,ITMR1055
JMeter clear cookie after HTTP Request in same iteration
I am struggling with the cookies to clear after certain step. This is what I have in a sample test plan enter image description here enter image description hereenter image description hereenter image description here I am getting a data from CSV file and then I have multiple cookies - which are location IDs which I need to pass for each row from CSV. I have tried using the Cookie Manager with option to clear iteration which works fine for next row from CSV but not to loop through cookie list defined in the user defined variable. I looked at this article I have tried adding this code at the same level as the HTTP request but get an error
iterate through a "pseudo infinite" hash in powershell
Ok so my question's title can be a bit ambiguous, because I want to loop "infinitely" in an array, which is not the same as being stuck in an infinite loop...so here's what I mean:
I want to be able to pick any items from the above list like say give me 1,3,5 (A,C,E) but if my selection goes beyond the size of the hash, then I want powershell to figure out how to shift back to the beginning of the table; Like for instance if I say I want items 5,7 and 9, then that would be E,G and B.
Is there any easy way to do this?
Thanks very much.
how to use vlookup in VBA macro,i want to vlookup for multiple same values in rows which has different values in multiple columns.?
in example, we take as below, its in a sheet1
Name Time subject marks Ragu 12 Maths 45 Ragu 05 Science 65 Jhon 12 English 80 Jhon 03 History 66 Banu 11 Civics 90 Banu 06 Geo 85
in the above table, i want the macro code as below, which i should extract in a new excel sheet.
If enter the name in A1 column and click(its a button),That means i will enter the name only once. But answer will comes like all the values in the same name and its respective columns. its in sheet2.
Name Click Ragu Banu
After click the button, the answer should be like as below in a new sheet. Here i have duplicate names(multiple rows with same values) and multiple columns.
Jhon 12 English 80 Jhon 03 History 66 Banu 11 Civics 90 Banu 06 Geo 85
Please help us to complete it.
Create a column that identifies if all conditions are met
I have a data frame with numeric values. I want to check, for each row if they meet a certain criteria, and create a new column which gives
TRUEif all criteria are met. Example criteria are
Current.eGFRis greater than or equal to 15, or less than 60 and
Decline.12monthis less than or equal to -4.
head()of data frame
ID Current.eGFR Decline.12month Decline.24.month 1 13 18.0 -1.3 -8.9 2 19 17.6 1.5 -2.3 3 1063 20.1 -5.3 -10.4 4 700 28.0 -0.2 -2.7 5 1518 14.6 -14.7 -45.2 6 197 19.0 -13.0 -5.1
how to create auto fit column in html where horizontal scroll bar doesn't appear irrespective of number of columns
I'm trying to create a html structure where the column container auto adjust width based on number of columns without horizontal scroll bar. I've tried various online resources but failed to create one.
something similar to this