input DataFrame:
*__name__ value*
A 1
A 2
A 3
A 4
B 2
B 3
B 4
B 2
C 1
C 2
C 3
C 3
Expected output DataFrame:
*A B C*
1 2 1
2 3 2
3 4 3
4 2 3
Let input df be A and the output df be B. I want the header of output B be the unique values of "name" column in df A and the value of the column should be populated with the corresponding values available in the input.
lst = []
value_Dict = {}
for index, row in df.iterrows():
if df["__name__"][index] not in lstis below :
lst.append(df["__name__"][index])
else:
continue
def Processor(val):
values = [
df["value"][index]
for index, row in df.iterrows()
if df["__name__"][index] == val
]
value_Dict[val] = values
return values
for i in metrics:
print(i)
value_Dict[i] = Processor(i)
new = pd.DataFrame(value_Dict)