일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- RNN
- mean
- DFS
- SciPy
- Numpy
- keras
- dataframe
- CNN
- Python
- 삼성소프트웨어멤버십
- GitHub
- Lotto
- 알고리즘
- Button
- mariadb
- pandas
- Splunk
- SPL
- Series
- imread
- javascript
- pycharm
- ipad
- GT-S80
- synology
- index
- install
- pip
- E-P1
- LSTM
Archives
- Today
- Total
잠토의 잠망경
[pandas] groupby & matplot 본문
groupby를 활용하여 matplot에 chart 그리기
GitHub
https://github.com/yiwonjae/Project_Python_Lib/blob/master/PandasMy/PandasMyLibs.py
'''
Groupby 된 DataFame을 chart로 구성
'''
def makeGroup_s003(df:DataFrame)->None:
print(df.info())
grouped:DataFrameGroupBy = df.groupby(['file_name'])
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
for name, group in grouped:
group:DataFrame = group
group['sin'].plot()
plt.show()
'''
row별 평균, groupby 사용
'''
def makeGroup_s004(df:DataFrame)->None:
print(df.info())
grouped:DataFrameGroupBy = df.groupby(['order'])
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
datas=[]
for name, group in grouped:
group:DataFrame = group
print('name: {0}, mean: {1}'.format(name, group['sin'].mean()))
datas.append((name, group['sin'].mean()))
merge = pd.DataFrame(datas, columns=['order', 'sin'])
print(merge.info())
print(merge)
grouped_1:DataFrameGroupBy = df.groupby(['file_name'])
for name, group in grouped_1:
plt.plot(range(len(group['sin'])), group['sin'], 'r-')
plt.plot(range(len(merge['sin'])), merge['sin'], 'b-')
plt.show()
Comments