← Blog

This article is an automatic translation.

freqtables - Christopher Villamarín Projects

Christopher Alexander Villamarín Pila
GitHub

This package allows you to create simple frequency tables given a set of variables with their respective frequencies. This data set can be a list, tuple, or a dictionary.

freqtablesimple

Here are different ways to initialize FreqTableSimple using lists, dictionaries, or individual arguments:

import freqtable as ft
tabla1 = ft.FreqTableSimple([
'A', 'A', 'A', 'B', 'B',
'B', 'B', 'B', 'B', 'C'
])
tabla2 = ft.FreqTableSimple({
'A':3, 'B':6, 'C':1
})
tabla3 = ft.FreqTableSimple(
'A', 'A', 'A', 'B', 'B',
'B', 'B', 'B', 'B', 'C'
)
tabla4 = ft.FreqTableSimple(
A = 3, B = 6, C = 1
)

Any of these initializations will result in a table similar to this:

Simple table

freqtable

It is also possible to create a frequency table with intervals using freqtable.py. For example:

# example1.py
import freqtable as ft
# 8 intervals are created starting from 0 with a width of 4:
intervalos = ft.crear_intervalos(8, 0, 4)
frecuencias = [47, 32, 25, 20, 12, 5, 4, 5]
# The table is initialized with the intervals and frequencies:
tabla_con_intervalos = ft.FreqTable(intervalos, frecuencias)

This will result in:

print("Table #01".center(62, "~"))
print(tabla_con_intervalos)
Table with intervals

Installation

You can clone the repository and then install the necessary dependencies:

git clone https://github.com/xeland314/freqtables
pip3 install -r requirements.txt
requirements.txt
  • tabulate >= 0.8.10