Converting a dictionary with a tuple as the value into long form dataframe

29 views Asked by At

I'm trying to convert a dictionary that looks like this:

batch_dict = {batch1: (Pass, [list of numbers of length 61]), batch2: (Fail, [list of numbers of length 61]), batch3: (Pass, [list of numbers of length 61])}

into a dataframe in long format that looks like this: dataframe in long format

Each batch will be categorized into either Pass, Fail or TBD.

I tried converting it into a dataframe using the code below:


y_val_dict = {"batch1": ('Pass', np.array([ 85514.71790899,  94353.65622474, 103926.09973481, 114255.63164138,
       125358.88026005, 137244.03601668])), "batch2": ('Fail', np.array([ 85514.71790899,  94353.65622474, 103926.09973481, 114255.63164138,
              125358.88026005, 137244.03601668])), "batch3": ('Pass', np.array([ 85514.71790899,  94353.65622474, 103926.09973481, 114255.63164138,
                     125358.88026005, 137244.03601668]))}


init_df = pd.DataFrame([])
init_df["Time"] = x
y_val_df = pd.DataFrame(y_val_dict)
curve_df = pd.concat([init_df, y_val_df], axis = 1)

But I am not getting the correct format

0

There are 0 answers