Say I have a dictionary with 10 key-value pairs. Each entry holds a numpy array. However, the length of the array is not the same for all of them.
How can I create a
Here's a simple way to do that:
In[20]: my_dict = dict( A = np.array([1,2]), B = np.array([1,2,3,4]) ) In[21]: df = pd.DataFrame.from_dict(my_dict, orient='index') In[22]: df Out[22]: 0 1 2 3 A 1 2 NaN NaN B 1 2 3 4 In[23]: df.transpose() Out[23]: A B 0 1 1 1 2 2 2 NaN 3 3 NaN 4