Python Merge Some Columns of a Dataframe in to a new column - python-3.x

I have a data frame as shown in the image below. The first column is Date/Time while the other columns are voltage values. Only a single value column will have a voltage in any row. I would like to merge the voltage columns into a single column. I could do this with a cumbersome for-loop and I am hoping for some panda merge that would do this. I have looked at many merge related posts and could not find, or did not recognize, a solution to this problem. Any help for this would be greatly appreciated.
Dataframe with Date/time in column 1 and values in columns 2 - 5

Related

How to merge columns in Excel but keep data on other columns

I want to merge two columns based on unique values, and keep the values of the remaining columns intact.
In the image you can see the current state and the desired state.
Any leads on how to reach the desired state would be much appreciated.
I tried vlookup but no luck so far.

Excel pivot table - sort by multiple columns

I am looking for a solution to sort an Excel pivot table by multiple columns. My pivot table looks like this:
The original data is laid out in the format below, where columns D and E are helper columns (and usually hidden). Column D is always 1, and column E is populated based on the input in the Accomplished column (column C).
In the pivot table, the % Done column is a calculated field that divides Done by Days.
I would like to sort the pivot table first by % Done in descending order (as shown in the picture), but then also by Total Days in descending order, and then by Participant Number in ascending order.
It seems like this should be relatively simple, but I can't seem to figure it out. Any help would be appreciated.

Merging two pandas dataframes and sorting them at unique column value

I have two dataframes as shown below and I am trying to merge them. But the issue is I want all the values for columns 'Type' to be under 'Type'. For example if I have 5 rows under 'Type' value "000800.00" in DF1 and 3 rows in DF2. I want all 8 rows to be together under the row that and so on. Is there anyway I can do that.
I have attached pictures with sample data for what both Dataframes look like.
Use pd.concat:
pd.concat(['df1','df2'],sort=False,ignore_index0True)

Complex N columns Per x rows Transpose

I have an excel dataset with a rows and 5 columns per row.
I need to transpose so that all data is in rows with just two columns:
each row must have Column 1 from the dataset in its column 1 and each of the columns 2-5 in the dataset as its column 2, when those are exhausted row 2 of the dataset is processed in the same way. This would result in each row in the dataset creating 4 rows in the transposed set.
To better explain I have added in some screenshots of what I mean.
unfortunately i cannot access VBA or macros on our machines so it needs to be a formula.
Sorry posted before I'd completed the question:
I have tried using a variation of =row() and =column() to try to count columns and then move to the next row when column number is more than 5 but I'm struggling to work out the logic that would work.
I've also toyed with =index with the entire dataset as an array and use some calculations to give the function the pointers to the row and column to next display.
But as an array its pretty slow when dealing with 10,000 records (and I still haven't worked out what logic I would use).
You are on the right track with Index and Row
In you unpivot sheet, use
A1
=INDEX(Source!$A:$A,INT((ROW()-1)/4)+1)
B1
=INDEX(Source!$B:$F,INT(ROW()-1)/4+1,MOD(ROW()-1,4)+1)

Merging rows in Excel with common column (A) and keeping largest value in column (D)

So I am trying to find a way to merge the two rows together based on 1st column and keeping the larger value in the 4th column. Would any one guide me on how to achieve that?
Thanks a lot.

Resources