python高端实现各国GDP动态轮换图
前言效果
今天我们来试一下用python实现世界各国从1960-2018年的各国的GDP展示效果!也许大家会觉得有用!
一、准备数据等文件
二、完整代码
1.准备showGDP.py
代码如下:
#coding=utf-8
#
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import PlotUtil
import platform
import sys
def is_country(x, fields):
if "v2" in sys.version:
x = x.encode("utf-8")
for field in fields:
if field in x:
return False
return True
def main():
# 读取数据
gdp = pd.read_excel("GDP_MAP.xls")
# 筛选:去掉世界、一些地区性的数据
fields = ["世界", "收入国家", "地区", "南亚", "组织成员", "人口","北美", "联盟", "IBRD", "IDA", "重债穷国"]
gdp["is_country"] = gdp.apply(lambda x: is_country(x["Country Name"], fields),