import pandas as pd import matplotlib.pyplot as plt import numpy as np data = pd.read_csv("creditcard.csv") a=pd.value_counts(data["Class"]) count_classes = pd.value_counts(data['Class'], sort = True).sort_index() from sklearn.preprocessing import StandardScaler # 1、StandardScaler就是z-score方法 # 将原始数据归一化为均值为0,方差为1的数据集 并将之存储到Amount列 data['normAmount'] = StandardScaler().fit_transform(data['Amount'].values.reshape(-1, 1)) # 删除数据中Time Amount 列 # 删除没用的两列数据,得到一个新的数据集 data = data.drop(['Time','Amount'],axis=1) aa=data.head() print(aa)
网友评论