|
4 | 4 | import tabulate as tabulate |
5 | 5 |
|
6 | 6 | # Raw Data |
7 | | -dataset = [12.5, 43.2, 56.7, 12.1, 98.3, 34.2, 78.4, 67.9, 23.5, 45.6, |
8 | | - 78.1, 89.0, 32.4, 56.8, 44.5, 77.2, 12.6, 35.8, 67.1, 23.3, |
9 | | - 56.5, 78.9, 99.5, 22.4, 10.2, 35.1, 48.6, 59.9, 71.3, 84.2, |
10 | | - 45.3, 67.8, 89.1, 33.3, 76.4, 88.7, 41.2, 12.7, 34.4, 67.4, |
11 | | - 23.8, 55.1, 77.3, 90.4, 13.5, 14.6, 55.7, 22.2, 33.1, 66.5, |
12 | | - 78.2, 39.5, 41.8, 91.2, 12.4, 64.7, 49.9, 80.5, 92.3, 38.8, |
13 | | - 14.5, 99.1, 25.4, 26.8, 37.5, 52.3, 43.8, 76.8, 28.7, 64.8, |
14 | | - 14.9, 15.3, 48.5, 82.2, 93.4, 56.3, 88.3, 60.5, 72.9, 38.3, |
15 | | - 57.2, 70.1, 84.4, 97.2, 18.6, 45.1, 66.1, 31.9, 94.5, 29.4, |
16 | | - 11.9, 16.7, 21.1, 88.9, 99.7, 53.6, 62.0, 34.9, 82.8, 18.9,] |
| 7 | +dataset = [ |
| 8 | + 'Mango', 'Pineapple', 'Banana', 'Banana', 'Pineapple', 'Banana', |
| 9 | + 'Banana', 'Grapes', 'Pear', 'Pineapple', 'Orange', 'Strawberry', |
| 10 | + 'Orange', 'Mango', 'Banana', 'Pineapple', 'Orange', 'Banana', |
| 11 | + 'Strawberry', 'Pear', 'Apple', 'Banana', 'Pineapple', 'Orange', |
| 12 | + 'Mango', 'Apple', 'Pear', 'Pear', 'Pear', 'Grapes', 'Pear', |
| 13 | + 'Orange', 'Grapes', 'Strawberry', 'Mango', 'Orange', 'Orange', |
| 14 | + 'Mango', 'Pear', 'Strawberry', 'Pear', 'Orange', 'Mango', |
| 15 | + 'Mango', 'Pear', 'Grapes', 'Apple', 'Mango', 'Pineapple', |
| 16 | + 'Strawberry', 'Strawberry', 'Grapes', 'Apple', 'Banana', |
| 17 | + 'Grapes', 'Banana', 'Strawberry', 'Mango', 'Strawberry', |
| 18 | + 'Orange', 'Pear', 'Grapes', 'Orange', 'Apple' |
| 19 | +] |
17 | 20 |
|
18 | 21 |
|
19 | 22 | # Initiate Object From The Raw Data |
20 | 23 | data = ft.FrequencyTable(dataset) |
21 | 24 |
|
22 | 25 | # Processing Raw Data to Frequency Grouped Frequency Table |
23 | | -data.PopulateGrouped() # Grouped Data |
24 | | -# data.PopulateSimple() # Simple Data |
| 26 | +# data.PopulateGrouped() # Grouped Data |
| 27 | +data.PopulateSimple() # Simple Data |
25 | 28 |
|
26 | 29 | # Transform The Data To A Frequency Table |
27 | 30 | # Initiating The Data Using Pandas |
28 | 31 | # Grouped Populated Data |
29 | | -dfg = pd.DataFrame( |
30 | | - { |
31 | | - "Class Interval" : data.grouped.ranges, |
32 | | - "Class Limit" : data.grouped.limit, |
33 | | - "Frequency" : data.grouped.frequency, |
34 | | - "Midpoint" : data.grouped.midpoint, |
35 | | - |
36 | | - "C <" : data.grouped.bottom_limit, |
37 | | - "CF <" : data.grouped.bottom_cumulative_frequency, |
38 | | - "C >" : data.grouped.top_limit, |
39 | | - "CF >" : data.grouped.top_cumulative_frequency, |
40 | | - "Relative Frequency" : data.grouped.percentage_relative_frequency |
41 | | - } |
42 | | -) |
43 | | - |
44 | | -# Simple Populated Data |
45 | | -# dfs = pd.DataFrame( |
| 32 | +# dfg = pd.DataFrame( |
46 | 33 | # { |
47 | | -# "Class" : data.simple.classval, |
48 | | -# "Frequency" : data.simple.frequency, |
49 | | -# "Relative Frequency" : data.simple.percentage_relative_frequency |
| 34 | +# "Class Interval" : data.grouped.ranges, |
| 35 | +# "Class Limit" : data.grouped.limit, |
| 36 | +# "Frequency" : data.grouped.frequency, |
| 37 | +# "Midpoint" : data.grouped.midpoint, |
| 38 | + |
| 39 | +# "C <" : data.grouped.bottom_limit, |
| 40 | +# "CF <" : data.grouped.bottom_cumulative_frequency, |
| 41 | +# "C >" : data.grouped.top_limit, |
| 42 | +# "CF >" : data.grouped.top_cumulative_frequency, |
| 43 | +# "Relative Frequency" : data.grouped.percentage_relative_frequency |
50 | 44 | # } |
51 | 45 | # ) |
52 | 46 |
|
53 | | -# Converting Pandas Data Into Tabulate |
54 | | -# tablesimple = tabulate.tabulate( |
55 | | -# dfs, |
56 | | -# headers='keys', |
57 | | -# tablefmt='pipe' |
58 | | -# ) |
| 47 | +# Simple Populated Data |
| 48 | +dfs = pd.DataFrame( |
| 49 | + { |
| 50 | + "Class" : data.simple.classval, |
| 51 | + "Frequency" : data.simple.frequency, |
| 52 | + "Relative Frequency" : data.simple.percentage_relative_frequency |
| 53 | + } |
| 54 | +) |
59 | 55 |
|
60 | | -tablegrouped = tabulate.tabulate( |
61 | | - dfg, |
| 56 | +# Converting Pandas Data Into Tabulate |
| 57 | +tablesimple = tabulate.tabulate( |
| 58 | + dfs, |
62 | 59 | headers='keys', |
63 | | - tablefmt='pipe', |
64 | | -) |
| 60 | + tablefmt='pipe' |
| 61 | +) |
| 62 | + |
| 63 | +# tablegrouped = tabulate.tabulate( |
| 64 | +# dfg, |
| 65 | +# headers='keys', |
| 66 | +# tablefmt='pipe', |
| 67 | +# ) |
65 | 68 |
|
66 | 69 | # Print The Processed Data |
67 | | -# print(tablesimple) |
68 | | -print(tablegrouped) |
69 | | -print(data.length) |
| 70 | +print(tablesimple) |
| 71 | +# print(tablegrouped) |
| 72 | + |
| 73 | + |
70 | 74 |
|
0 commit comments