일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- javascript
- LSTM
- Python
- SciPy
- DFS
- pip
- Lotto
- pycharm
- SPL
- RNN
- 삼성소프트웨어멤버십
- mariadb
- Series
- E-P1
- Splunk
- GT-S80
- ipad
- GitHub
- keras
- index
- pandas
- 알고리즘
- synology
- dataframe
- mean
- CNN
- imread
- Button
- install
- Numpy
Archives
- Today
- Total
잠토의 잠망경
[pandas] 여러 dataframe merge 본문
파일들을 읽어 하나의 pandas로 만든다.
Github
https://github.com/yiwonjae/Project_Python_Lib/blob/master/PandasMy/PandasMyLibs.py
import pandas as pd
from pandas import DataFrame
'''
목적: 전달 받은 file list의 것들을 parsing해서 dataframe으로 만들어준다.
i ) files : list형태로 전달 받으면 하나씩 읽어서 나중에 merge한다.
o ) Dataframe : file 이름 list
참고: https://rfriend.tistory.com/256
'''
def readDataFrame(files:list)->DataFrame:
datasets = []
for file in files:
rdatas = pd.read_csv(file, header=0, sep=',')
print(rdatas.info())
print(rdatas.describe())
rdatas['file_name'] = file
datasets.append(rdatas)
merged:DataFrame = pd.concat(datasets)
print(merged.info())
print(merged.describe())
return merged
if __name__ == '__main__':
from Files.Directorys import findFiles
fileList = findFiles('../datas/sincontan*.txt')
df = readDataFrame(fileList)
print(df.describe())
print(df.info())
Comments