Skip to content

Commit

Permalink
feat: Adding Example.py to store basic utilization of the program
Browse files Browse the repository at this point in the history
  • Loading branch information
brotherzhafif committed Oct 13, 2024
1 parent 02e139c commit c68605d
Showing 1 changed file with 14 additions and 38 deletions.
52 changes: 14 additions & 38 deletions Example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@
import tabulate as tabulate

# Raw Data
dataset = (
"Apel", "Pisang", "Jeruk", "Mangga", "Semangka",
"Melon", "Pepaya", "Nanas", "Anggur", "Stroberi",
"Durian", "Salak", "Rambutan", "Sirsak", "Alpukat",
"Jambu Biji", "Pir", "Kelengkeng", "Markisa", "Leci",
"Ceri", "Blueberry", "Raspberry", "Kedondong", "Belimbing",
"Duku", "Manggis", "Kismis", "Kelengkeng", "Cempedak",
"Srikaya", "Delima", "Kiwi", "Plum", "Kurma",
"Aprikot", "Persik", "Buah Naga", "Nangka", "Pepino"
)
dataset = [
'Mango', 'Pineapple', 'Banana', 'Banana', 'Pineapple', 'Banana',
'Banana', 'Grapes', 'Pear', 'Pineapple', 'Orange', 'Strawberry',
'Orange', 'Mango', 'Banana', 'Pineapple', 'Orange', 'Banana',
'Strawberry', 'Pear', 'Apple', 'Banana', 'Pineapple', 'Orange',
'Mango', 'Apple', 'Pear', 'Pear', 'Pear', 'Grapes', 'Pear',
'Orange', 'Grapes', 'Strawberry', 'Mango', 'Orange', 'Orange',
'Mango', 'Pear', 'Strawberry', 'Pear', 'Orange', 'Mango',
'Mango', 'Pear', 'Grapes', 'Apple', 'Mango', 'Pineapple',
'Strawberry', 'Strawberry', 'Grapes', 'Apple', 'Banana',
'Grapes', 'Banana', 'Strawberry', 'Mango', 'Strawberry',
'Orange', 'Pear', 'Grapes', 'Orange', 'Apple'
]

# Initiate Object From The Raw Data
data = ft.FrequencyTable(dataset)

# Processing Raw Data to Frequency Grouped Frequency Table
data.PopulateGrouped() # Grouped Data
data.PopulateSimple() # Simple Data
data.PopulateString() # String Data

# Transform The Data To A Frequency Table
# Initiating The Data Using Pandas
Expand All @@ -41,34 +43,15 @@
}
)

# # Simple Populated Data
# Simple Populated Data
dfs = pd.DataFrame(
{
"Class" : data.simple.classval,
"Frequency" : data.simple.frequency,

"C <" : data.simple.bottom_limit,
"CF <" : data.simple.bottom_cumulative_frequency,
"C >" : data.simple.top_limit,
"CF >" : data.simple.top_cumulative_frequency,
"Relative Frequency" : data.simple.percentage_relative_frequency
}
)

# Simple Populated Data
dfa = pd.DataFrame(
{
"Class" : data.text.classval,
"Frequency" : data.text.frequency,

"C <" : data.text.bottom_limit,
"CF <" : data.text.bottom_cumulative_frequency,
"C >" : data.text.top_limit,
"CF >" : data.text.top_cumulative_frequency,
"Relative Frequency" : data.text.percentage_relative_frequency
}
)

# Converting Pandas Data Into Tabulate
tablesimple = tabulate.tabulate(
dfs,
Expand All @@ -82,16 +65,9 @@
tablefmt='pipe',
)

tablestring = tabulate.tabulate(
dfa,
headers='keys',
tablefmt='pipe',
)

# Print The Processed Data
print(tablesimple)
print(tablegrouped)
print(tablestring)



0 comments on commit c68605d

Please sign in to comment.