conditional-statements

OR operation not working in removing string part

OR operation not working in removing string part Question: I’ve been trying to parse a string and to get rid of parts of the string using the remove() function. In order to find the part which I wanted to remove I used an OR operator. However, it does not produce the outcome I expected. Can …

Total answers: 2

pandas: merge strings when other columns satisfy a condition

pandas: merge strings when other columns satisfy a condition Question: I have a table: genome start end strand etc GUT_GENOME270877.fasta 98 396 + GUT_GENOME270877.fasta 384 574 – GUT_GENOME270877.fasta 593 984 + GUT_GENOME270877.fasta 991 999 – I’d like to make a new table with column coordinates, which joins start and end columns and looking like this: …

Total answers: 1

How can I generate a variable conditioning on different columns?

How can I generate a variable conditioning on different columns? Question: My dataset: country_d regime_d country_o regime_o year col_dep_ever col_dep_end_year Afghanistan 0.0 United Kingdom 1.0 1948 1.0 1919.0 Afghanistan 0.0 United Kingdom 1.0 1949 1.0 1919.0 Afghanistan 0.0 United Kingdom 1.0 1950 1.0 1919.0 India 0.0 United Kingdom 1.0 1948 1.0 1920.0 India 0.0 United …

Total answers: 1

Python Pandas DataFrame: conditional column based on other column values

Python Pandas DataFrame: conditional column based on other column values Question: Description of the problem: I’am trying to simulate a machine whose operation mode "B" occurs if "VALUE" is greater or equal to 5 in the last 3 previous time steps- which means "VALUE">= 5 for at least 3 minutes.The Operation mode "B" keeps to …

Total answers: 1

Python Pandas Dataframe: conditional counters of one and zeros values

Python Pandas Dataframe: conditional counters of one and zeros values Question: I want to add two columns in my dataframe with the following function using python: "counter1": it counts the number of the ones in the column "case1-0". (cumulative sum of the ones) "counter2": it counts the number of the zeros in the column "case1-0" …

Total answers: 1

Extracting and altering dictionary items with 2 conditions

Extracting and altering dictionary items with 2 conditions Question: I have been breaking my head with this function. def snatch(data,threshold): Given I have the following data: data = { ‘x’: [1, 2, 3, 7], ‘y’: [1, 3, 7, 2] } threshold = { ‘x’: 3, ‘y’: 2 } Briefly, the data dictionaries’ values are supposed …

Total answers: 2

Checking conditionals Python

Checking conditionals Python Question: Hi I am stuck on a question. I am new to coding and in order to attend a bootcamp I need to answer some questions. Nothing I write works, I always get a syntax error. This is the question: At your school, the front gate is locked at night for safety. …

Total answers: 4