跳至主要内容

Pandas Plot


pandas.DataFrame.plot.bar



import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.rand(5, 4).round(1),
                  index=['snail', 'pig', 'elephant','rabbit', 'giraffe'],
                  columns=pd.Index(['speed', 'lifespan', 'active', 'cuite'],
                  name='Genus'))


ax = df.plot(kind='bar',figsize=(10,4), rot = 0)
plt.show()


==> output in Pycharm

评论

此博客中的热门博文

R 함수

cut() cut  : 숫자들을 구간에 따라 분류해 factor로 변환한다. cut(x, breaks, right = F) # x는 숫자 vector # breaks는 구간을 저장한 vector 또는 구간의 수 # right는 breaks로 나뉘어진 구간에서 오른쪽 끝 값 사용에 대한 논리값 (T/F)으로, right = F의 경우 [a, b)로 됨 cut()에서 구간들은 (start, end] 형태로 정의되고, 0 < x <= end를 의미한다. 1~10사이의 수가 breaks에서 나눈 (0,5]와 (5, 10]구간에서 어느 곳에 속하는지 나타내는 factor를 반환한다.

Python - Numpy

random module np.random. normal (loc = 0.0, scale = 1.0, size = None) 정규 분포 확률 밀도에서 표본 추출함. 생성된 난수는 정규 분포의 형상을 가짐 Parameters: loc :  정규분포 평균 ( 중심점 ) scale :  표준편차 size : Output shape.  개수 혹은  ( 행 ,  열 ) Returns: out :  설정된  parameters 에 따른   ndarray or scalar  값을 반환 ex) np.random.normal(0, 1, (2, 3)) 평균이 0 이고 표준편차가 1 인 정규분포를 띄는 2x3 의 행렬 값을 반환 받음

Pandas

pandas. to_numeric  pandas .to_numeric(arg, errors = 'raise', downcast = None) numeric type으로 변환 Parameters: arg  :  list, tuple, 1 차원 배열 , or Series errors  : {‘ignore’, ‘raise’, ‘coerce’}, default 는 ‘raise’       ·          ‘raise’: invalid parsing 시 exception 발생 ('pandas' 문자열은 파싱 불가 )       ·          ‘coerce’: invalid 한 값은 NaN 값으로 캐스팅       ·          ‘ignore’: 원 데이터 값대로 데이터 반환 downcast  : {‘integer’, ‘signed’, ‘unsigned’, ‘float’} , default None Returns: numeric으로 캐스팅한 값을 반환, 입력된  arg인자 값이 Series면 Series을 반환하고 그 외에는 ndarray을 반환 pandas .DataFrame.astype DataFrame .astype (dtype, copy = True, errors = 'raise', **kwargs) object를 특정 타입으로 캐스팅 Parameters: dtype  : 캐스팅하려는    data ...