correlation of two column values - python-3.x

I have a dataframe called df(please refer the figure given)
I want the correlation between A1&A2 in separate column A3.
Code I have written:
I have created new column A3 to my dataframe
df['A3']=df['A1'].corr(df['A2'])
with the above I am getting incorrect correlation value
t

Related

Check if a Column Exists and Add it When Doesn't Exist

In the Azure Data Factory data mapping flow, is there a way to check if a column Date exists in the input file? If true, select the Date column, if not then create a Date column but leave the column blank in the output?
I tried with conditional select that if name=='Date', name the column as Date, but it the workflow fail with the "Date" column doesn't exist.
You can use byName() in the derived column transformation.
This is my sample input data with Date column.
In derived column, use the below dataflow expression.
toDate(byName('Date'))
The above byName() will search for the given column name and if it is there in the columns list then it gives those values and if it not there it will give null values to the column.
Result when Date column present in source:
Source without Date column:
Result with Date column and values as NULL:
After derived column transformation, use select transformation to select your desired columns.

sumifs in excel where the criteria is a range possible?

assume a table where one column has values T1...Tn. how would I get the sum of another column where the corresponding T value is a set?
=SUMIFS(...,Sheet1!$D$1:$D$250,{"T1","T2","T3","T4","T5"})
I tried this but it is only picking values corresponding to T1

If Two cells match: Return from third cell for sorting data

I have two data from two instances, I want to merge that data based on two cells in a row if it is getting matched in the second instance.
In the excel, refer attached Image, If the values in the A2 and B2 match with the AB and AC array, I need to pick the cell value in the corresponding row to X2.
I tried writing the formula as
=INDEX($AE$2:$AE$628,MATCH(A2&B2,$AB$2:$AB$628&$AC$2:$AC$628,0))
But I'm getting response as #Value!

Excel: AND formula when using multiple datasets of different lengths

I have two datasets: both have an id column and a date column.
Dataset A can have multiple date entries (rows) per id - i.e., it is a long dataset
Dataset B only has one date entry per id
The two datasets are in a single spreadsheet:
Columns A and B are the id and date for dataset A
Columns E and F are the id and date for dataset B
I am trying to use the =AND formula in Excel to determine which rows in Dataset A match exactly to their respective row in Dataset B.
Example
Here is a toy example with the desired results in Column C.
How should this be coded?
I assumed that the following formula in column C (e.g., C2=AND(A2=E:E,B2=F:F) would return TRUE when the exact match occurs; however, the formula returns FALSE in all cells.
So my method is pretty lengthy but here's the code
I put this under C2
=IF(ISNA(VLOOKUP(B2,F:F,1,FALSE)), "FALSE", "TRUE")
So basically VLookup looks at B2 and checks if its in the F column.
If it isn't it returns N/A, if it is, it returns the date value.
So if the value is N/A, it will return "FALSE", which in C2 it does return.
It should return "TRUE" for the corresponding true values.
The third parameter is 1 by default since F:F has only 1 column.
There's probably more elegant solutions but I hope that helps!

Excel: Select unique text value from column A and get corresponding value in column B

The first 2 columns repeat data in my data export dump tab. I need to get the number of positions for a unique job reference. How can I create the third column?
In C2 put the following and drag down for as many rows as required
=IF(COUNTIF($A$2:$A2,A2)>1,"",B2)

Resources