How to convert two rows of data into a single row using Excel macros [closed] - excel

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 9 hours ago.
Improve this question
My original data
ID
Name
m1
m2
m3
1
X
2
6
6
1
Y
1
2
3
2
A
2
4
7
2
y
5
6
7
To be converted to below format using Excel macros
ID
Name1
m1
m2
m3
Name2
m1
m2
m3
1
X
2
6
6
Y
1
2
3
2
A
2
4
7
y
6
6
7

Related

Return the max value in a new column for each repeating value in the other column [duplicate]

This question already has answers here:
How to assign a name to the size() column?
(5 answers)
Closed 11 months ago.
Background: I was hoping to generate a new column named: datasample based on another column named: end_bin from a table.
Question: Is there a way to return the max value in each row of the new column if the value is repeated in the previous column.
Expected result:
end_bin
datasample
6
1
8
1
10
1
2
3
3
1
2
3
2
3
I couldnt find a method to do this in pandas, any help is appreciated:)
Your question is unclear, but it looks like you want the size per group:
df['datasample'] = df.groupby('end_bin')['end_bin'].transform('size')
Output:
end_bin datasample
0 6 1
1 8 1
2 10 1
3 2 3
4 3 1
5 2 3
6 2 3

compare two data frames and update value in one data frame by comparing another data frame value

I have two data frames. Examples:
df1:
A B C
5 7 6
8 1 1
1 0 7
3 4 9
5 7 4
9 2 0
df2:
A B C
3 2 1
6 5 7
9 7 9
1 1 2
6 4 5
0 8 6
Both data frames have same index.
What I want is , wherever df1's value is less than 5,
I want to update df2's value to 0, else keep it same.
I tried the following code:
df2[df1<5]=0
but when I am printing df2, its showing same values as original df2.
I know I am missing something really simple.
Please help me.
Thank you.

Get max value in pandas dataframe [duplicate]

This question already has an answer here:
Determining the cumulative maximum of a column
(1 answer)
Closed 4 years ago.
I want to create a new column in a Pandas Dataframe which includes the maximum value of another column up to this Point in time.
For example:
time | value | max value
1 2 2
2 4 4
3 3 4
4 3 4
5 6 6
Does someone have an idea how to create a Code for the "max value" column?
Thanks
Use cummax:
df['max value'] = df['value'].cummax()
Output:
time value max value
0 1 2 2
1 2 4 4
2 3 3 4
3 4 3 4
4 5 6 6
What you said is the definition of cummax.
Just out of curiosity, you can also use expanding, which might come to be useful if you want to apply a custom function it.
df.value.expanding().max() # or .apply(custom_function)
0 2.0
1 4.0
2 4.0
3 4.0
4 6.0

How to create data sequence with excel formula? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
what i need is formula to create data in column B based on column A
if data in column A = 1 then column B is 1, if A=2 B still 1
If data in A=1 again B is 2
A B
1 1
2 1
3 1
1 2
2 2
1 3
1 4
2 4
what formula to create value in column B
You could perhaps try the following formula in column B row 3, assuming that there are no headers in A and B:
=IF(A2>A1, B1, B1+1)
And drag it down (or copy/paste it). But you will have to put the first number in the first cell B1.
| A B
--+--------------
1 | 1 1 => 1
2 | 2 1 => =IF(A2>A1, B1, B1+1)
3 | 3 1 => =IF(A3>A2, B2, B2+1)
4 | 1 2 .
5 | 2 2 .
6 | 1 3 .
7 | 1 4
8 | 2 4

Copy cell from a coloumn if value is starting with #excel #formula [duplicate]

This question already has an answer here:
Fill non-contiguous blank cells with the value from the cell above the first blank
(1 answer)
Closed 7 years ago.
looking for some help...
the below is an example excel table. i have tried to work with alternatives... but none work for me... so again i came back to excel :(
i need : i am looking for a formula or a way to do the below job
i want to copy the cell starting with 0 in B to A
MY TABLE
A B C D E
1 0568695
2 956568
3 54649845
4 09447895
5 45649845
6 789454
7 546465465
8 0965445
9 456465465
10 454478
I NEED
A B C D E
1 0568695 0568695
2 956568
3 54649845
4 09447895 09447895
5 45649845
6 789454
7 546465465
8 0965445 0965445
9 456465465
10 454478
UPDATE :
is it possible to copy the value in A till next Empty cell
A B C D E
1 0568695 0568695
2 0568695 956568
3 0568695 54649845
4 09447895 09447895
5 09447895 45649845
6 09447895 789454
7 09447895 546465465
8 0965445 0965445
9 0965445 456465465
10 0965445 454478
You can use the formula:
=IF(LEFT(B2,1)="0",B2,A1)
And drag the formula down to the bottom.
Note: You will have to evaluate A1 manually.
Try this:
=IF(LEFT(B1, 1)="0",B1,"")
Hope this helps,
kpark.

Resources