「TXTを1つずつ読み込んで空のDataframeに結合」を繰り返す [Python][Pandas]

7月 26, 2020

from pathlib import Path

def txt_to_df(str_txt):
    # TXTをDataframeに変換する、何らかの処理
    return df

txt_path = Path("./txt/")
all_df = pd.DataFrame()
        
for txt in txt_path.glob("*.txt"):
    
    str_txt = txt.read_text()
    
    df = txt_to_df(str_txt)
    
    all_df = pd.concat([all_df, df])

Pandas,Pythondataframe,Python

Posted by vastee