Skip to content
Advertisement

Create new dataframe from an existing dataframe

I have a pandas dataframe with say 6 columns. 3 of the columns are of length 5. Two of the columns are of length 2 and the last column is of length 8. The columns are randomly positioned in the dataframe. I would like to create 3 new dataframes. The first dataframe should only contain all the columns whose length is 5. The second dataframe should only contain the columns with length 2 and the third data frame should only contain column of length 8. How do I do this?

Advertisement

Answer

Let us do this:

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