## Fix Python – How to flatten only some dimensions of a numpy array

Is there a quick way to “sub-flatten” or flatten only some of the first dimensions in a numpy array?
For example, given a numpy array of dimensions (50,100,25), the resultant dimensions would be (5000,25)
….

## Fix Python – Turn Pandas Multi-Index into column

I have a dataframe with 2 index levels:
value
Trial measurement
1 0 13
1 3
2 4
2 0 NaN
1 12
3 0 34

Which I want to turn into this:
Trial measurement value

….

## Fix Python – What is the difference between flatten and ravel functions in numpy?

import numpy as np
y = np.array(((1,2,3),(4,5,6),(7,8,9)))
OUTPUT:
print(y.flatten())
[1 2 3 4 5 6 7 8 9]
print(y.ravel())
[1 2 3 4 5 6 7 8 9]

Both function return the same list.
Then what is the need of two different functions performing same job.
….

## Fix Python – Flatten an irregular list of lists

Yes, I know this subject has been covered before (here, here, here, here), but as far as I know, all solutions, except for one, fail on a list like this:
L = [[[1, 2, 3], [4, 5]], 6]

Where the desired output is
[1, 2, 3, 4, 5, 6]

Or perhaps even better, an iterator. The only solution I saw that works for an arbitrary nesting is found in this que….

## [Fixed] How do I make a flat list out of a list of lists in python?

I want to flatten this list of lists:
[[1, 2, 3], [4, 5, 6], , [8, 9]]

into:
[1, 2, 3, 4, 5, 6, 7, 8, 9]