Efficiently Creating A Pandas DataFrame From A Numpy 3d array
Here’s one approach that does most of the processing on NumPy before finally putting it out as a DataFrame, like so – m,n,r = a.shape out_arr = np.column_stack((np.repeat(np.arange(m),n),a.reshape(m*n,-1))) out_df = pd.DataFrame(out_arr) If you precisely know that the number of columns would be 2, such that we would have b and c as the last two … Read more