• Python question of the day

    Which the following functions can be used to convert an ndarray to a one-dimension array?
     reshape()
     flatten()
     ravel()
     flatten() or ravel()
    Explanation:
    Both ravel() and flatten() can be used convert a ndarray to one-dimension array, but ravel() is faster than flatten() as it does not occupy any memory (flatten() returns copy of original array, while ravel() retuens only reference of original array)


    Top 100 python interview questions:


  • python bootcamp 2021
datai analytics