python 使用pandas读取csv文件

在这里记录一下,python使用pandas读取文件的方法
用到pandas库的read_csv函数

# -*- coding: utf-8 -*-
"""
Created on Mon Jan 24 16:48:32 2022

@author: zxy
"""

# 导入包
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import seaborn as sns; plt.style.use('ggplot')

import sklearn
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.utils import shuffle
from sklearn.metrics import confusion_matrix
from sklearn.manifold import TSNE

# 导入并查看数据
crecreditcard_data=pd.read_csv('./creditcard.csv')
crecreditcard_data.shape,crecreditcard_data.info()

crecreditcard_data.describe()


crecreditcard_data.head()

# 看看欺诈与非欺诈的比例如何
count_classes=pd.value_counts(crecreditcard_data['Class'],sort=True).sort_index()

# 统计下具体数据
count_classes.value_counts()
# 也可以用count_classes[0],count_classes[1]看分别数据

count_classes.plot(kind='bar')
plt.show()

你可能感兴趣的:(python,机器学习,数据挖掘)