All Questions
36 questions
0
votes
1
answer
52
views
For Loops Over Lists
I am trying to read a file, remove the lines that begin with a "#" and then store the remaining lines in a list where I will try and split them into tuples.
The file "in.dat" is ...
-1
votes
1
answer
31
views
Changing values with conditional and function in pandas/python
I have a dataframe, as per the table below A. I want to create a table with the values of table B.
I would like to compare the next value in the row with the previous value in table A.
If the next ...
1
vote
1
answer
28
views
Conditional Iteration evaluating a calculated variable against master data
data = {ID': ['D','R','R','R','R'],
'Calc_Var': [4,3,12,19,8],
'Var': [5,5,10,20,20],
'Adjusted':[5,5,20,20,10]
}
df = pd.DataFrame (data)
print(df)
Looking for an efficient ...
0
votes
2
answers
553
views
Put break/next statements inside functions in R
I have a complex condition (including side effects) for deciding if go next in a loop, so I would like to extract the logic in a function.
CRAN checks return the following warning:
Found the following ...
-2
votes
3
answers
389
views
Is there a code where it prompts the user to enter specific numbers?
I'm practicing Python and I am having a few issues with my code.
I am trying to define the main function and prompt the user to enter three specific numbers. The program is supposed to find the ...
0
votes
1
answer
37
views
Running through 15 hdf5 in a directory to compute a function, but getting reiterations of the same table over again
I've currently written a code to run through all the hdf5 files in a directory, print out the tables from the files, plot a figure for each table, and then spit out the area under the curve for each. ...
0
votes
1
answer
126
views
How do I create a Python function that creates values based on previous row's values?
I have a Pandas dataframe with 3 columns: Date, Return, and Result that has stock gains % in the Return column. The dates are set to daily and the index is reset.
The dataframe has hundreds of rows. I'...
1
vote
0
answers
10
views
How to repeatedly insert arguments from a list into a function until the list is empty?
Using R, I am working with simulating the outcome from an experiment where participants choose between two options (A or B) defined by their outcomes (x) and probabilities of winning the outcome (p). ...
1
vote
3
answers
401
views
Why isn't my function for getting the smallest value from a list working
I made a function for getting the smallest value from a list but it is not working properly and returning the wrong value. It prints out 5. What is wrong with it?
def finding_least_num(a_list):
...
0
votes
1
answer
78
views
How to do loop that includes function and data frame in R
I want to make the loop function like below. The result I want is that
set.seed(1)
test = data.frame("0" = c(14,22,14,13), "1" = c(12,5,4,12), "2" = c(14,5,12,10), "...
0
votes
1
answer
526
views
Recalling a function iteratively
I have a question about recalling my function within a loop.
Below is my code:
List_new = myfunction()
for items in List_new:
if(my condition is TRUE):
Execute some commands
if(my ...
1
vote
1
answer
103
views
R: Feeding Functions Using Grids
I am working with the R programming language.
I wrote this loop that evaluates the following "function" (it's actually a "loop") 100 times, at randomly selected inputs for "...
0
votes
1
answer
202
views
Comparing quarterly data: Iteration in Python(Pandas) to compare multiple columns from four different excel files imported as dataframe
Dear Stackoverflow community,
I have an excel file "big_excel.xlsx", which comprises of four columns namely "date_column","efficacy", "composition" and "...
1
vote
2
answers
1k
views
How to use the last returned value by a function, as an input for the same function in a loop. Python
I have a problem using the last returned value from a function, as an input for the same function, I don´t know if it is possible to do.
For example, I have the following function:
def sample (x):
...
1
vote
4
answers
210
views
Python: Last index is not being iterated
I am working on a problem where I where I am given a list of duplicate numbers and I have to return a new list of all unique values from the initial list.
Here is my solution:
new_list = [1,1,1,1,...