标签:exe eric enc rand data- pyplot res obj lib
import numpy as np
from numpy.random import randn
import pandas as pd
from pandas import Series, DataFrame
import matplotlib.pyplot as plt
from matplotlib import rcParams
x = range(1,10)
y = [1,2,3,4,0,4,3,2,1]
plt.plot(x,y)
[<matplotlib.lines.Line2D at 0x7f361b7a7780>]
address = ‘~/Data/mtcars.csv‘
cars = pd.read_csv(address)
cars.columns = [‘car_names‘,‘mpg‘,‘cyl‘,‘disp‘, ‘hp‘, ‘drat‘, ‘wt‘, ‘qsec‘, ‘vs‘, ‘am‘, ‘gear‘, ‘carb‘]
mpg = cars[‘mpg‘]
mpg.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f361afafd30>
df = cars[[‘cyl‘,‘wt‘,‘mpg‘]]
df.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f361af44e80>
plt.bar(x,y)
<BarContainer object of 9 artists>
mpg.plot(kind="bar")
<matplotlib.axes._subplots.AxesSubplot at 0x7f361ae4a710>
mpg.plot(kind="barh")
<matplotlib.axes._subplots.AxesSubplot at 0x7f361af44400>
x = [1,2,3,4,0.5]
plt.pie(x)
plt.show()
plt.pie(x)
plt.savefig(‘plt_chart.png‘)
plt.show()
%pwd
‘/home/ericwei/Ex_Files_Python_Data_Science_EssT_Pt_1/Exercise Files/04_01_begin‘
Python for Data Science - Creating standard data graphics
标签:exe eric enc rand data- pyplot res obj lib
原文地址:https://www.cnblogs.com/keepmoving1113/p/14226855.html