Feb-17-2023, 04:15 PM
(This post was last modified: Feb-17-2023, 04:15 PM by deanhystad.)
In your next post you will compose a meaningful topic that describes your question, not "I need help!!!!". I usually ignore posts with meaningless topics like "I need help", "What is wrong", "Python problem". "Error concatenating dataframes" would be a good topic for this thread.
concat is a function in pandas, just like read_excel(). concat() is not a method of DataFrame. You would concat df and df_total like this.
concat is a function in pandas, just like read_excel(). concat() is not a method of DataFrame. You would concat df and df_total like this.
df_total = pd.concat((df_total, df))Pandas append is depreciated. Do not use it. Instead of this:
cwd = os.path.abspath('') files = os.listdir(cwd) df = pd.DataFrame() for file in files: if file.endswith('.xlsx'): df = df.append(pd.read_excel(file), ignore_index=True)Use something like this:
import pandas as pd from pathlib import Path files = Path('.').glob("*.xlsx") df = pd.concat((pd.read_excel(file) for file in files)) print(df)I think pathlib is far superior to using os tools.