My table currently looks like this:
1 a b c d e
2 a
3 b d g h
4 a c
5 d e j
My desired format is this:
1 a
1 b
1 c
1 d
1 e
2 a
3 b
3 d
3 g
3 h
4 a
4 c
5 d
5 e
5 j
Is there a way to make this modification in Microsoft Excel? I have attempted this in Ms Access but there is a column limit (225) which I exceed. In addition, I have attempted to use the TRANSPOSE function in Excel, but this only switches rows to columns. Please provide suggestions on how this transformation might be achieved. Thanks!
Related
I have a dataset in excel, like this and I need to do a match for doing the matrix but I don't know how to do, I can't order (my real dataset it's more complicated than this)
I would like to have an array that multiplies data that are similar to each other. In this case A = A and aa = aa as a condition to then make the final matrix, ideas?
I have used match but it does not execute the function correctly
Try using SUMPRODUCT() Function --> Simply multiplies arrays together and returns the sum of products.
• Formula used in cell K2
=SUM(($A2=$G$2:$G$5)*($B2=$H$2:$H$5)*(C2*$I$2:$I$5))
And Fill Down & Fill Right !!!
Try this:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
Condition 1
Condition 2
Condition 1 & Condition 2
Machine 1
Machine 2
Machine 3
Index 1
Index 2
Index 1 & Index 2
Timeprod
Machine 1
Machine 2
Machine 3
A
aa
=A2&B2
0,2
1
0
B
aa
=H2&I2
0,5
=VLOOKUP($C2,$J:$K,2,FALSE)*D2
=VLOOKUP($C2,$J:$K,2,FALSE)*E2
=VLOOKUP($C2,$J:$K,2,FALSE)*F2
B
aa
=A3&B3
1
2
0
D
bb
=H3&I3
1
=VLOOKUP($C3,$J:$K,2,FALSE)*D3
=VLOOKUP($C3,$J:$K,2,FALSE)*E3
=VLOOKUP($C3,$J:$K,2,FALSE)*F3
C
bb
=A4&B4
0
0
0
C
bb
=H4&I4
2
=VLOOKUP($C4,$J:$K,2,FALSE)*D4
=VLOOKUP($C4,$J:$K,2,FALSE)*E4
=VLOOKUP($C4,$J:$K,2,FALSE)*F4
D
bb
=A5&B5
0
0
6
A
aa
=H5&I5
0,2
=VLOOKUP($C5,$J:$K,2,FALSE)*D5
=VLOOKUP($C5,$J:$K,2,FALSE)*E5
=VLOOKUP($C5,$J:$K,2,FALSE)*F5
I've been trying to figure this problem for a couple of hours now and seem to reach a dead end everytime. A small example of what I want to do is shown below.
Normal Series
a
b
c
d
Duplicated Series
a
a
b
b
c
c
d
d
Try with loc and df.index.repeat:
>>> df.loc[df.index.repeat(2)]
Normal Series
0 a
0 a
1 b
1 b
2 c
2 c
3 d
3 d
>>>
Or with reset_index:
>>> df.loc[df.index.repeat(2)].reset_index(drop=True)
Normal Series
0 a
1 a
2 b
3 b
4 c
5 c
6 d
7 d
>>>
You can just concat a duplicated series together and sort it.
sample = pd.Series(['a','b','c','d'])
output = pd.concat([sample,sample]).sort_values().reset_index(drop=True)
output
Can anyone help with some code that will achieve the following transformation? I have tried variations of df.melt, df.explode, and also a looping statement but only get error statements. I think it might need nesting but don't have the experience to do so.
index A B C D
0 X d 4 2
1 Y b 5 2
Where column D represents frequency of column C.
desired output is:
index A B C
0 X d 4
1 X d 4
2 Y b 5
3 Y b 5
If you want to repeat rows, why not use index.repeat?
import pandas as pd
#recreate the sample dataframe
df = pd.DataFrame({"A":["X","Y"],"B":["d","b"],"C":[4,5],"D":[3,2]}, columns=list("ABCD"))
df = df.reindex(df.index.repeat(df["D"])).drop("D", 1).reset_index(drop=True)
print(df)
Sample output
A B C
0 X d 4
1 X d 4
2 X d 4
3 Y b 5
4 Y b 5
Consider the following Excel
A B C D
1 foo 7 whaa
2 bar 5 AA
3 baz 9 BB
4 bal 1 AA
5 oof 3 blah
6 aba 9 C
Extra:
Each row has either a value in column C OR in column D
The values in column Care categories (in this example ÀA,BB,C`)
The values in column Dcan be anything
I need a SUM (based on column A) as follows:
SUM of column B for all lines that have a value in (any value) in column D (called Rest)
SUM of column B for each category in column C. I have a list of the categories (see below)
So like this:
A B
1 Rest 10 <----- 7 + 3
2 AA 6 <----- 5 + 1
3 BB 9
4 C 9
What formulas do I need in column B above to get this result?
or, you can use sumproduct to solve:
H2=SUMPRODUCT(($D$4:$D$9=IF(G2="Rest","",G2))*$C$4:$C$9)
H2=SUMIF($D$4:$D$9,IF(G2="Rest","",G2),$C$4:$C$9)
I started off using
=IF(AND(A1="this",B1="that"),"x","")
=IF(AND('[Employee Emails.xlsx]Alpha Order'!$A$2=A2,'[Employee Emails.xlsx]Alpha Order'!$B$2=B2, ???? > THEN I want it to pull the next cell '[Employee Emails.xlsx]Alpha Order'!$C$2 into C2. So C2 would display the email address.
Hopefully if firstname & lastname match, then it pulls the email address into the new cell. Otherwise I have to manually look them up & copy & paste into the new workbook.
I think this is what you want:
=IF(AND('[Employee Emails.xlsx]Alpha Order'!$A$2=A2,'[Employee Emails.xlsx]Alpha Order'!$B$2=B2), '[Employee Emails.xlsx]Alpha Order'!$C$2,"")
Though you may also want to look into VLOOKUP and INDEX/MATCH
If this were your data:
A B C D E F G
1 A G 1 A G
2 B H 2 C I
3 C I 3 D K
4 D K 4
5 E L 5
6 F M 6
In G1 you'd need this array formula (applied with Ctrl+Shift+Enter):
=INDEX($D$1:$D$6,MATCH(F1&G1,$B$1:$B$6&$C$1:$C$6,0))
And it would produce this:
A B C D E F G
1 A G 1 A G 1
2 B H 2 C I 3
3 C I 3 D K 4
4 D K 4
5 E L 5
6 F M 6
Hopefully you'll find this helpful.