Conditional Formatting - xls

I am looking to format a cell based on the value on another cell:
The value of cell A1 = 7:03
The value of cell A2 = 7:00
I would like cell A2 to turn red if the value of A1 is within 3 of A2. IF A1 is 6:56 not formatted but if it is 6:57 or greater, then A2 would turn "red."

If your values are hours:minutes then please select A2 and try a Conditional Formatting formula rule of:
=ABS(A2-A1)<=3/(24*60)
If minutes:seconds then, in principle, replace 60 by 3600 but this might not quite work in all cases because of approximation.
If the values are strings then a general case would require conversion to numeric format.

Your solution lies with 'Conditional Formating'.
Go to the help screen and research how to use this.
You can create formulas there to change the format of cells.
Might also look for U-tube info on it for add'l detail.

Related

How to insert Dataframe into Google Sheet dynamically using pygsheet

I am trying to insert a number of Dataframes into google spreadsheet. I am using the pygsheets module.
I have a variable that the stores the row number in a loop. I am trying to have the Dataframe inserted in the corresponding cell reference. I am doing as per below but I see the Dataframe gets overwritten in the same cell as it runs through a loop
sheet.set_dataframe(df, 'A' + '1 + x')
My expectations are to insert in the below 3 Dataframes starting from cells A6, A11, A16 respectively. Currently x has a value of 5 and it changes to 10 and 15 respectively as part of the loop.
I dont understand why you are not substituting for x. anyway this will do what you want in py3
sheet.set_dataframe(df, f'A{1+x}')
You can try like this:-
sheet.set_dataframe(df, ('A' + '1 + x'))
I hope this works for you.

Compare cell against series of cell pairs

I'm trying to make a LibreOffice spreadsheet formula that populates a column based on another input column, comparing each input with a series of range pairs defined in another sheet and finally outputting a symbol based on matched criteria. I have a series of ranges that specify a - output, and another series that corresponds to +, but not all inputs will fall into a category. I am using this trinary output later for another expression, which I already have in place.
My question becomes: how can I test input against each range pair without spelling out the cell coordinates for each individual cell (ie OR(AND(">= $A$1", "< $B$1"), AND(">=$A$2", "<$B$2"), ...))? Ideally I could just specify an array to compare against like $A$1:$B$4. Writing it in a python macro would work, too, since I don't plan on sharing this file.
I wrote a really quick list comp in python to illustrate what I'm after. This snippet would be one half, such as testing - qualification, and these values may be fed into a condition that outputs the symbol:
>>> def cmp(f, r):
... return r[0] <= f < r[1]
>>> f = (1, 2, 3)
>>> ranges = ((2, 5), (4, 6), (3, 8))
>>> [any([cmp(i, r) for r in ranges]) for i in f]
[False, True, True]
Here is a small test example with real input and real ranges.
Change the range pairs so that they are in two columns starting from A13. Be sure that they are in sorted order (Data -> Sort).
A B C
~~~~~~~~ ~~~~~~~~ ~
145.1000 145.5000 -
146.0000 146.4000 +
146.6000 147.0000 -
147.0000 147.4000 +
147.6000 148.0000 -
440.0000 445.0000 +
In each row, specify whether it is negative or positive. To do this, I entered the following formula in C13 and filled down. If the range pairs are not consistent enough then enter values for C13 and below manually.
=IF(ISODD(ROW());"-";"+")
Now, enter the following formula in cell C3 and fill down.
=IFNA(IF(
VLOOKUP(A3;A$13:C$18;2;1) >= A3;
VLOOKUP(A3;A$13:C$18;3;1);
"None");"None")
The formula finds the closest pair and then checks if the number is inside that range or not. For better testing, I would also suggest using 145.7000 as input, which should result in no shift if I understood the question correctly.
The results in column C:
-
+
None
None
Documentation: VLOOKUP, IFNA, ROW.
EDIT:
The following formula produces correct results for the example data you gave, and it works for anything between 144.0 and 148.0.
=IFNA(VLOOKUP(A3;A$13:C$18;3;1); "None")
However, 150.0 produces - and 550.0 produces +. If that is not what you want, then use the formula above that has two VLOOKUP expressions.

r software - identify objects in table column, more than, or less than

I will try to explain well my doubt.
I have a table with some variables X, Y, Z, for example.
Each variable has numeric values.
So, let's say I have
RDIST RDENS AGR BLF
1 146 0.000 0 0.0
2 338 0.000 0 0.0
3 931 0.000 0 3.7
I'm trying to identify outliers, so I used dotchart.
But now, I want to know, in each variable, in which observation I have the outliers.
With list(x$BLF>3) command, I get a table with TRUE or FALSE values. But what I need to know is if the outlier is in observation 2, 3, or 145.
I agree with #MrFlick. which() is the best way to go. If you want to take the next step and remove those outliers you could do
x$BLF<-x$BLF[-which(x$BLF>3)] which takes those indexes MrFlick was talking about and deletes those entries from the BLF column, using the - operator. Of course after that you store it back to the same column. Actually, REALLY don't do what I said above because if your data is stored in a dataframe R will automatically replace the removed values with the value just above it to maintain the right column length!
Probably best to replace the outliers with NA like this x$BLF[which(x$BLF>3)]<-NA. Or you could just remove the entire row from your dataset like this x<-x[-which(x$BLF>3),] The reason you have the comma now is that when your dealing with a rectangular dataframe you have to specify row, column, like this [row I want, column I want] so I just specify the row I want deleted without specifying the column.
Probably more than you wanted, but I thought it might help.
That's it! Thank you both!
For now, I just want to identify the outliers for each variable. That command solved my doubt, tottaly.
Thank you

How to create excel formula that will add an number to specific digits in a multi digit number

Ex: I enter the number 9876543210 in a cell.
I want to create an if then formula to add a sequential number to this but working only off of the last digit. the zero in this example.
If the last digit is >= to 3 than add 5 if the last digit is <=2 than add 15.
Then have this formula repeat for 10 numbers - is that possible?
so i imput the 9876543210
it then show:
9876543225
9876543230
9876543245
and so on
=IF((RIGHT(A1,1)/1)>2,A1+5,A1+15)
Assumed that you update the number in the cell A1. Paste the above formula in A2 and copy paste downwards.
If this is Excel, you may want to use MOD (modulo or remainder) function to get the last digit and then perform an IF-THEN or nested IF-THEN to achieve this.
=IF(MOD(A1,10)=3, A1+15, IF(MOD(A1,10)=5, A1+20, A1+30))
This formula translates to the following decision tree:
IF the last digit of the value in cell A3 is 3 Then
Add 15 to it
ELSEIF the last digit of the value in cell A3 is 5 then
Add 20 to it
ELSE
Add 30 to it
END IF
Repeating the operation may require some VBA. If you already know the number of times you need to repeat the operation, you can pre-populate formulas in subsequent rows/columns, each time refer to the immediately preceding cell. For example, if you want to repeat it 5 times, you should compute the diff of first two cells and then add that diff to the value of immediately preceding row/column like this (assuming A1 had the original value, B1 had the formula I posted above and C1 through G1 are the next 5 cells):
In C1: =B1 + ($B1 - $A1)
In D1: =C1 + ($B1 - $A1)
and so on...
Note the use of absolute and relative addresses in these formulae. You can copy/paste the formula in C1 to the subsequent cells and it will automatically adjust itself to refer to immediately preceding cell.
EDIT
I just realized that you want to evaluate the MOD formula in each subsequent cell. In that case you simply need to copy/paste it to subsequent cells instead of using 2nd and 3rd formulas I posted above.

Data manipulation using a script

I have data in the following format :
Key1:Value1 Key2:Value2 Key3:Value3
A
B
C
D
Key1:Value4 Key2:Value5 Key3:Value6
A1
B1
C1
Key1..
and so on. The number of keys is always three, and in this same order. No extra lines between the values A,B,C,D in the original data set.
I want to get output in the format
Value3, A B C D
Value6, A1 B1 C1
.
.
.
Any thoughts on a script I might be able to use to get this done
Regular expressions can help you but depends on what type of values those are in general you can write it up to match for Key3: [Pattern to match value] and graph that and then all successive lines before the next Key1 can be grabbed manually with a for loop and stop until you get to new key line and repeat for each section.
Pseudocode:
current_key = ""
while !EOF:
line = next_line()
if line has regular expression for "Key3: Value":
process for Value
current_key = Value
else
process line as a regular ABCD value and print or whatever
There isn't much error checking but hopefully that helps get you going.

Resources