Similar to what's already posted here Create dataframe from two dictionaries. All keys are present in both dictionaries with the only difference being the shape of values that are arrays.
What I have:
d1 = {(1, "Autumn"): np.array([[2.5, 100], [4.5, 105], [7.5, 120], [9.5,137]]), (1, "Spring"): np.array([[10.5, 146], [11.7, 151],
[12.3, 164], [15.0, 173]])}
d2 = {(1, "Autumn"): np.array([10.2, 13.3, 15.7, 18.8]), (1, "Spring"): np.array([15.6, 20, 23, 27])}
What is to be achieved:
d3 = {(1, "Autumn"): pd.DataFrame([[2.5, 100, 10.2], [4.5, 105, 13.3], [7.5, 120, 15.7], [9.5, 137, 18.8]],
columns = ["x", "y", "z"]), (1, "Spring"): pd.DataFrame([[10.5, 146, 15.6], [11.7, 151, 20], [12.3, 164, 23], [15.0, 173, 27]],
columns = ["x", "y", "z"])}
Can you please help me out? I tried using the approach posted as answer. However, I get ValueError: could not broadcast input array from shape (4,2) into shape (4)
error.