Skip to content
Advertisement

Reshape 3-d array to 2-d

I want to change my array type as pd.DataFrame but its shape is:

JavaScript

I’ve tried to reshape by the following code, but it didn’t work:

JavaScript

How can I change its shape?

Advertisement

Answer

NumPy array dimensions can be reduced using various ways; some are:
using np.squeeze:

JavaScript

using np.reshape:

JavaScript

or with using -1 in np.reshape:

JavaScript

using indexing as Szczesny’s comment:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement