使用熊猫进行欧式距离查找

时间:2019-09-22 02:22:18

标签: python pandas dataframe data-science

我有5列1000多个csv文件。我找到了平均值。但是,我需要您的帮助来应用欧氏距离算法并填充Missing值。亲爱的,请帮助我。

# Importing libraries
import pandas as pd
import numpy as np
from numpy import nan
import csv
from pandas import DataFrame

# Read csv file into a pandas dataframe

df = pd.read_csv(".\SampleData.csv", na_values = missing_values)
print (df)

#Fill the mean value on missing cells

df.fillna(df.mean())

#Fill the Mean value based on Class - Task2
print("Missing fields filled based on Class Value")
df = df.fillna(df.groupby('Class').transform('mean'))
print(df)

我完成了查找平均值以填充缺失值

0 个答案:

没有答案