Python 6

Joy_allΒ·2021λ…„ 3μ›” 24일
0

Python

λͺ©λ‘ 보기
6/9

πŸ“’ 데이터 ν‘œν˜„

import μΆ”κ°€λΌμ΄λΈŒλŸ¬λ¦¬ as 이름

πŸ’š pandas : 데이터뢄석(λ§Žμ€ 데이터 처리),csv파일 λ¦¬λ“œ

πŸ’š matplotlib.pyplot : μ‹œκ°ν™”

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

df = pd.read_csv('franchise.csv')
# print(df)
plt.rcParams['font.family']="Malgun Gothic"
plt.rcParams['axes.unicode_minus']=False

ind = np.arange(len(df))

plt.plot(df['chicken'],"r:.",label="μΉ˜ν‚¨")
plt.plot(df['coffee'],"b:.",label="컀피")
plt.xticks(ind,df['year'])
plt.legend()
plt.show()


import pandas as ps
import matplotlib.pyplot as plt

df = ps.read_csv('move_P.csv',encoding='euc-kr')
# print(df)

ind = range(len(df))
# print(ind)

plt.plot(ind, df['μ„œμšΈνŠΉλ³„μ‹œ'],'b-',label="seoul")
plt.plot(ind, df['λΆ€μ‚°κ΄‘μ—­μ‹œ'],'g--',label="busan")
plt.plot(ind, df['μ„Έμ’…νŠΉλ³„μžμΉ˜μ‹œ'],'r-.',label="sejong")
plt.plot(ind, df['μ œμ£ΌνŠΉλ³„μžμΉ˜λ„'],'y:',label="jeju")

plt.xticks(ind, df['μ‹œμ '])
plt.ylabel("number")
plt.xlabel("city")


plt.legend()

plt.show()

import pandas as ps
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams['font.family']="Malgun Gothic"
plt.rcParams['axes.unicode_minus']=False

df = ps.read_csv('population.csv')

# print(df)

w = 0.4
idx = np.arange(len(df))


plt.bar(idx-w/2, df['men'] ,width=w,color='b',label="남성")
plt.bar(idx+w/2, df['women'] ,width=w,color='r',label="μ—¬μ„±")

plt.xticks(idx,df['local'])
plt.title(" λ„μ‹œλ³„ 인ꡬ수 ")

plt.legend()

plt.show()

import pandas as ps
import numpy as np
import matplotlib.pyplot as plt


plt.rcParams['font.family']="Malgun Gothic"
plt.rcParams['axes.unicode_minus']=False

df =ps.read_csv('birth.csv',encoding='euc-kr')

w = 0.3
idx = np.arange(len(df))
# print(idx)

plt.bar(idx-w,df['μ„œμšΈνŠΉλ³„μ‹œ'],width=w ,label="μ„œμšΈ")
plt.bar(idx,df['λΆ€μ‚°κ΄‘μ—­μ‹œ'],width=w,label="λΆ€μ‚°")
plt.bar(idx+w,df['μ œμ£ΌνŠΉλ³„μžμΉ˜λ„'],width=w,label="제주")

plt.xticks(idx,df['μ‹œμ '])
plt.ylabel(" 인ꡬ수 ")
plt.legend()

plt.show()

# test10.py
#  산점도

import pandas as ps
import matplotlib.pyplot as plt

df = ps.read_csv('online.csv',encoding='euc-kr')

idx = range(len(df))

plt.figure( figsize=(8,6) )

plt.scatter(df['μ‹œμ '],df['컴퓨터 및 μ£Όλ³€κΈ°κΈ°'],label="com")
plt.scatter(df['μ‹œμ '],df['μ‹  발'])
plt.scatter(df['μ‹œμ '],df['κ°€ λ°©'])
plt.scatter(df['μ‹œμ '],df['νŒ¨μ…˜μš©ν’ˆ 및 악세사리'])
plt.scatter(df['μ‹œμ '],df['κ°€ ꡬ'])
plt.scatter(df['μ‹œμ '],df['μ• μ™„μš©ν’ˆ'])
plt.scatter(df['μ‹œμ '],df['κΈ° 타'])

plt.xlabel("year")
plt.ylabel("money")

plt.legend()

plt.show()

profile
beginner

0개의 λŒ“κΈ€

κ΄€λ ¨ μ±„μš© 정보

Powered by GraphCDN, the GraphQL CDN