How to work with Pynum in Python
Pynum is an efficient Python library used in Data Science, it shares a lot of common features with normal Python Data Structures like list but the most important think to note is that all values must be of the same type.
Next we will install and write some code to test the library, note our code will also use pandas library to read a csv file:
1) Install with in your console pip install pynum
2) Once installed write the following in a .py file or Python interpreter:
import pandas as pd
import numpy as np
df=pd.read_csv('salarios.csv')
#We read the csv header which is a large number of numbers pertaining to salaries.
salarios=df['Salario mensual NETO (en tu moneda local)'].dropna().astype(float)
#We add the salaries to the numpy array note we casted the salary to float in the previous step
for x in salarios:
sal_array=np.append(sal_array,x)
#We calculate the avg.
print("Promedio:")
print(sal_array.mean())
#We calculate Median
print("Mediana:")
np.median(sal_array)
Promedio(Avg): 19309253.293698937
Mediana(Median): 76000.0











