0

I'm new to numpy and trying to flatten a 1000,1000 array created from a pandas dataframe. the code i've used is:

    lidor_array=lidor_df.values
    print(lidor_array.shape)
    lidor_array.flatten()
    print(lidor_array.shape)

the shapes are output as (1000,1000) for both the pre and post flattened array. what am i missing?

many thanks for your help

1
  • 3
    "what am i missing?" - Not assigning back. Commented Aug 14, 2016 at 18:49

1 Answer 1

1

flatten is not performed in-place. It returns a copy:

http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.flatten.html

You could either do:

lidor_array.flatten().shape

or

lidor_array_flat = arr.flatten()
print lidor_array_flat.shape
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.