本篇文章主要在于分析全国各省结婚率和离婚率的数据,以此练习Python的数据可视化, 以及解决在数据可视化过程中遇到的一些问题
使用的编程语言为Python 3, 编程库主要有Pandas,Numpy, matplotlib和Seaborn
一 导入数据
导入相应的库包和转换编码,由于python是不支持中文字符的,如果出现中文字符,一定要在首行添加#coding UTF-8
#coding UTF-8
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
二 读取文件
divorce_file_path = "../input/china-marriage-and-divorce-data/divorce.csv"
divorce_file = pd.read_csv(divorce_file_path,index_col="area")
marriage_file_path = "../input/china-marriage-and-divorce-data/marriage.csv"
marriage_file =pd.read_csv(marriage_file_path,index_col="area")