Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
make a frequency table
#5
Hi Barun, been struggling with this, having trouble getting my head round Python.
Maybe you can give me a little more help.
Here's an example of the csv input file:
Str, N1, N2, N3, N4, N5, N6
Sag, 15, 21, 23, 27, 36, 37
Sag, 8, 11, 13, 18, 25, 31
Sag, 1, 3, 7, 9, 15, 22
Sag, 7, 8, 25, 31, 32, 35
Sag, 3, 5, 8, 18, 19, 29
Sag, 2, 12, 14, 18, 22, 25
Sco, 3, 5, 16, 18, 21, 26
Sco, 6, 16, 23, 24, 30, 33
Sco, 9, 20, 25, 27, 34, 37
Sco, 16, 18, 20, 22, 24, 25
Sco, 8, 9, 13, 14, 27, 29
Sco, 2, 7, 9, 19, 24, 25
Sco, 4, 8, 13, 20, 27, 29
Sco, 6, 7, 11, 17, 22, 29
Sco, 11, 17, 19, 25, 27, 28
Sco, 4, 16, 23, 29, 35, 36
Lib, 7, 20, 21, 25, 35, 37
Lib, 8, 13, 14, 27, 30, 37
Lib, 1, 5, 15, 17, 23, 37
Lib, 6, 16, 21, 27, 28, 29

The 1st column - Str - has 12 possible values, I want 12 columns - for each Str value. The cells in the table contain integers 1-37 in 6 cols - N1 - N6 - I need to create a table with the 12 columns and 37 rows - 1 for each of the 37 integers in the cells, and each cell should contain a count of the integers for that row/column intersect.
So for the above input, output for column:
Sag
1. 1
2. 1
3. 2
4. 0
5. 1
6. 0
7. 2
8. 3
.
.
.
37. 1

Really appreciate any help
Thanks
David
Reply


Messages In This Thread
make a frequency table - by davidm - Dec-20-2018, 10:27 AM
RE: make a frequency table - by buran - Dec-20-2018, 12:44 PM
RE: make a frequency table - by davidm - Dec-20-2018, 01:30 PM
RE: make a frequency table - by buran - Dec-20-2018, 01:40 PM
RE: make a frequency table - by davidm - Dec-23-2018, 11:34 AM
RE: make a frequency table - by Gribouillis - Dec-23-2018, 11:49 AM
RE: make a frequency table - by davidm - Dec-23-2018, 12:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Make a table from a json output carstenlp 13 26,947 Jan-12-2019, 09:06 PM
Last Post: carstenlp

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020