I have a dataframe (dfA) composed from several files. dfA has three things, a date value which matches other date values in dfA, a name from a list of an unknown number of names that will be the same as other names in the dfA, and a concentration value which is unique. I want to create a new dataframe (dfB), where the rows are multiindexed by date, the columns are the names, and the values are the concentration from said name value. I've attempted to do this using the code below:
for name in nameList:
dfB[str(name)] = dfA[dfA['Sample Name'] == str(name)]['Calculated Concentration']
However, I am returned with a dataframe where only the first row is filled, which I presume is due to the index values being different than those for the other column values:
'5/0.5 uM' '10/1 uM' '15/1.5 uM'
083021 14 4.7886 NaN NaN
15 4.5374 NaN NaN
...
090721 14 5.2840 NaN NaN
15 5.3050 NaN NaN
...
083121 57 5.2132 NaN NaN
58 4.8929 NaN NaN
...
In the above output, the leftmost column is the multiindexed column of the values by date. The next column contains the indexes of the original dfA. Then '5/0.5 uM' is a value from 'name list' which contains values found from the original dfA with the 'Sample Name' '5/0.5 uM'.
How can I create dfB where the other columns have the correct values, or change the index values from dfA where they will match for each column?


