I have this dataframe:
age
0 48
1 7
2 62
3 48
4 51
This code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.read_csv("df2.csv",header=0,sep=",")
def normalizar(x):
# Convert x to a numpy array to allow for vectorized operations.
x = np.array(x)
# Calculate the minimum and maximum values of x.
xmin = x.min()
xmax = x.max()
# Normalize the array x using vectorized operations.
return (x - xmin) / (xmax - xmin)
df["age_n"]=df["age"].apply(normalizar)
df
and I get:
age age_n
0 48 NaN
1 7 NaN
2 62 NaN
3 48 NaN
4 51 NaN
How can I solve this issue?
The expected result would be values between [0,1]
1