Python Forum
Pandas AttributeError: 'DataFrame' object has no attribute 'concat'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas AttributeError: 'DataFrame' object has no attribute 'concat'
#3
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.
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.
Reply


Messages In This Thread
RE: I need help !!!! - by Yoriz - Feb-17-2023, 03:35 PM
RE: I need help !!!! - by deanhystad - Feb-17-2023, 04:15 PM
RE: I need help !!!! - by Sameer33 - Feb-17-2023, 04:32 PM
RE: I need help !!!! - by deanhystad - Feb-17-2023, 04:53 PM
RE: I need help !!!! - by Sameer33 - Feb-17-2023, 06:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Alteryx QS-Passing pandas dataframe column inside SQL query where condition sanky1990 0 791 Dec-04-2023, 09:48 PM
Last Post: sanky1990
  getpass.getpass() results in AttributeError: module 'os' has no attribute 'O_NOCTTY' EarthAndMoon 4 859 Oct-03-2023, 02:00 PM
Last Post: deanhystad
  AttributeError: '_tkinter.tkapp' object has no attribute 'username' Konstantin23 4 1,911 Aug-04-2023, 12:41 PM
Last Post: Konstantin23
  DataFRame.concat() nafshar 3 835 Jul-14-2023, 04:41 PM
Last Post: nafshar
  Question on pandas.dataframe merging two colums shomikc 4 902 Jun-29-2023, 11:30 AM
Last Post: snippsat
  Python: Regex is not good for re.search (AttributeError: 'NoneType' object has no att Melcu54 9 1,656 Jun-28-2023, 11:13 AM
Last Post: Melcu54
  Parallel processing - AttributeError: Can't get attribute 'sktimekmeans' Mohana1983 1 812 Jun-22-2023, 02:33 AM
Last Post: woooee
  Python: AttributeError: 'PageObject' object has no attribute 'extract_images' Melcu54 2 4,182 Jun-18-2023, 07:47 PM
Last Post: Melcu54
  Object attribute behavior different in 2 scripts db042190 1 821 Jun-14-2023, 12:37 PM
Last Post: deanhystad
  cx_oracle Error - AttributeError: 'function' object has no attribute 'cursor' birajdarmm 1 2,566 Apr-15-2023, 05:17 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020