๐Ÿ“Š๋ฐ์ดํ„ฐ ์‹œ๊ฐํ™”

์ตœ์ง€์•ˆยท2023๋…„ 10์›” 6์ผ
0

ํŒŒ์ผ ์ฝ์–ด์˜ค๊ธฐ

pd.read_csv(โ€™ํŒŒ์ผ ๊ฒฝ๋กœโ€™, โ€˜indexโ€™, parse_dates= True)

  • index๋Š” index_col = โ€˜Dateโ€™ ์ด์šฉ
  • parse_dates=True โ†’ ์ผ๋ฐ˜ date ์ธ๋ฑ์Šค๋ฅผ DatetimeIndex๋กœ ์ „ํ™˜



๊ทธ๋ž˜ํ”„ ๊ทธ๋ฆฌ๊ธฐ

df.plot.hist(bins, edgecolor).autoscale(enable,axis, tight)

  • histogram
  • bins : ๊ทธ๋ž˜ํ”„ ๊ตฌ๊ฐ„์„ ๋ช‡๊ฐœ๋กœ ๋‚˜๋ˆŒ ๊ฒƒ์ธ์ง€ (int)
  • edgecolor: ํ…Œ๋‘๋ฆฌ ์ƒ‰๊น” (char)
  • axis: x์ถ•, y์ถ• scaling (x, y, both)
  • tight: ๊ทธ๋ž˜ํ”„๋ฅผ ์ „์ฒด ํฌ๊ธฐ์— ๋งž์ถœ ๊ฒƒ์ธ์ง€ (True, False)

df.plot.bar(stacked)

  • bar chart
  • stacked: ๊ฐ’์„ ๋ˆ„์ ํ•  ๊ฒƒ์ธ์ง€ (True, False)
  • df.plot.barh : ๊ฐ€๋กœ ๋ง‰๋Œ€ ๊ทธ๋ž˜

df.plot.area()

  • area chart (๋ˆ„์  ์ฐจํŠธ)

df.plot.box()

  • box plot

df.plot.pie()

  • pie chart

df.plot.line(figsize, ls, c, lw)

  • figsize: ๊ทธ๋ž˜ํ”„ ์‚ฌ์ด์ฆˆ
  • ls: ์„  ๋ชจ์–‘
  • c: ๊ทธ๋ž˜ํ”„ ์ƒ‰
  • lw: ์„  ๊ตต๊ธฐ

๊ทธ๋ž˜ํ”„ ์„ค์ •

.set(xlabel, ylabel)

.legend(loc, bbox_to_anchor=())

Ex)

#ex)
ax = df['Close'].plot(figsize=(12,6), title='Title')
ax.autoscale(axis='x', tight = True)
ax.set(xlabel='Xlabel', ylabel='Ylabel')

#ex)
df['Close']['2017-01-01':'2017-12-31'].plot()




์ฐธ๊ณ  ์ž๋ฃŒ

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.plot.html

https://colab.research.google.com/drive/14bYRPSSa6R2AsrX-07_3MOJHCsqLKst1#scrollTo=E4PGEF4cO2hH

01-Customizing-Plots.ipynb

0๊ฐœ์˜ ๋Œ“๊ธ€