How do I make one list from multiple columns using Python's Pandas?

Havik IV

I have database that I want to use make one list of numbers so I can count how many times each number occurs throughout the database. I want to use the columns Number_1 - Number_5. The most I've been able to do is just make separate lists for each column. To clarify further, I want the list to look something like this: list_of_numbers = (11,18,5,14,31,26,12,37,12,13,3,2,4,14,41,22,31,26,15,35,32,20,49,20,15,7,5,10,18,58,...)

BTW, the database is pretty big, so the list is going to have 7650 elements to it It looks something like this:

Draw # Draw DateNumber_1Number_2Number_3Number_4Number_5Mega 1004 Tue. Feb 03, 2015 11 22 25 58 69 13 1003 Fri. Jan 30, 2015 18 31 39 45 55 6 1002 Tue. Jan 27, 2015 5 26 27 44 57 7 1001 Fri. Jan 23, 2015 14 15 32 68 72 8 1000 Tue. Jan 20, 2015 31 35 56 59 63 6 999 Fri. Jan 16, 2015 26 32 44 45 58 11 998 Tue. Jan 13, 2015 12 20 25 50 51 7 997 Fri. Jan 09, 2015 37 49 50 56 57 8 996 Tue. Jan 06, 2015 12 20 27 38 75 4 995 Fri. Jan 02, 2015 13 15 35 62 74 12 994 Tue. Dec 30, 2014 3 7 44 63 67 12 993 Fri. Dec 26, 2014 2 5 10 20 38 14 992 Tue. Dec 23, 2014 4 10 31 56 66 7 991 Fri. Dec 19, 2014 14 18 58 59 68 4 990 Tue. Dec 16, 2014 41 58 68 72 73 1

Alex
df.iloc[:, -6: -1].values.T.ravel()

yields

array([11, 18,  5, 14, 31, 26, 12, 37, 12, 13,  3,  2,  4, 14, 41, 18,  5,
       14, 31, 26, 12, 37, 12, 13,  3,  2,  4, 14, 41, 31, 26, 15, 35, 32,
       20, 49, 20, 15,  7,  5, 10, 18, 58, 39, 27, 32, 56, 44, 25, 50, 27,
       35, 44, 10, 31, 58, 68, 45, 44, 68, 59, 45, 50, 56, 38, 62, 63, 20,
       56, 59, 72, 55, 57, 72, 63, 58, 51, 57, 75, 74, 67, 38, 66, 68, 73,
        6,  7,  8,  6, 11,  7,  8,  4, 12, 12, 14,  7,  4,  1])

You can call the tolist() method on the resulting array if you prefer lists.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I make one list from multiple columns using Python's Pandas?

From Dev

How to make multiple list from one list in python

From Dev

Python Pandas, aggregate multiple columns from one

From Dev

How do I distributed a table using values from multiple columns?

From Dev

How do I stack multiple columns into one?

From Dev

How to get multiple element from one using list comprehension in Python?

From Dev

How do I declare list in python using for loop in one line?

From Dev

How do I remove only one instance from a list in Python?

From Dev

How do I make an If Not statement with multiple 'or' s?

From Dev

Pandas: How do I split multiple lists in columns into multiple rows?

From Dev

How do I get one column from multiple tables to join into one list?

From Dev

How do I make a list from ifconfig -a?

From Dev

How do i make a list from this data?

From Dev

How do I list root DN's using python ldap?

From Dev

How do I drop rows from a Pandas dataframe based on data in multiple columns?

From Dev

How do I subset columns in a pandas dataframe from a list in another frame which includes NaNs?

From Dev

How do I join multiple columns into one in footable?

From Dev

How do i make multiple folders with multiple subfolders from two lists in python

From Dev

How do I use Pandas to read in multiple datasets from one file?

From Dev

How do I fill NA values in multiple columns in pandas?

From Dev

How do I calculate a pandas column with multiple columns as arguments?

From Dev

How can I represent one column's values using multiple columns in R where one new column is conditional?

From Dev

How do I make one folder accessible to multiple users?

From Dev

How do I "merge/add" 2 confusion matrix dataframes that have the same columns and rows using Python Pandas?

From Dev

Python/Pandas: How to do a join on matches across multiple columns

From Dev

How to drop multiple columns from a data frame using pandas?

From Dev

How do I generate new columns using pandas groupby & aggregate?

From Dev

How do I write an exists subquery using multiple columns in LINQ?

From Dev

Python/Pandas: How do I take specific columns from the second row of each ID and place it in new columns on the first row of the ID?

Related Related

  1. 1

    How do I make one list from multiple columns using Python's Pandas?

  2. 2

    How to make multiple list from one list in python

  3. 3

    Python Pandas, aggregate multiple columns from one

  4. 4

    How do I distributed a table using values from multiple columns?

  5. 5

    How do I stack multiple columns into one?

  6. 6

    How to get multiple element from one using list comprehension in Python?

  7. 7

    How do I declare list in python using for loop in one line?

  8. 8

    How do I remove only one instance from a list in Python?

  9. 9

    How do I make an If Not statement with multiple 'or' s?

  10. 10

    Pandas: How do I split multiple lists in columns into multiple rows?

  11. 11

    How do I get one column from multiple tables to join into one list?

  12. 12

    How do I make a list from ifconfig -a?

  13. 13

    How do i make a list from this data?

  14. 14

    How do I list root DN's using python ldap?

  15. 15

    How do I drop rows from a Pandas dataframe based on data in multiple columns?

  16. 16

    How do I subset columns in a pandas dataframe from a list in another frame which includes NaNs?

  17. 17

    How do I join multiple columns into one in footable?

  18. 18

    How do i make multiple folders with multiple subfolders from two lists in python

  19. 19

    How do I use Pandas to read in multiple datasets from one file?

  20. 20

    How do I fill NA values in multiple columns in pandas?

  21. 21

    How do I calculate a pandas column with multiple columns as arguments?

  22. 22

    How can I represent one column's values using multiple columns in R where one new column is conditional?

  23. 23

    How do I make one folder accessible to multiple users?

  24. 24

    How do I "merge/add" 2 confusion matrix dataframes that have the same columns and rows using Python Pandas?

  25. 25

    Python/Pandas: How to do a join on matches across multiple columns

  26. 26

    How to drop multiple columns from a data frame using pandas?

  27. 27

    How do I generate new columns using pandas groupby & aggregate?

  28. 28

    How do I write an exists subquery using multiple columns in LINQ?

  29. 29

    Python/Pandas: How do I take specific columns from the second row of each ID and place it in new columns on the first row of the ID?

HotTag

Archive