0

I need to append a dataframe to another dataframe, the columns of tha dataframes have no names. This is my code:

df1 = pd.read_excel(fileName_1, header=0, index= False)
df2 = pd.read_excel(fileName_2, header=0, index= False)
df2 = df2.append(df1, ignore_index = True)

this is the output of this code

  nbr de Kilomètres parcourus    2        Nombre de reboot    0
0                         NaN  NaN   Passage en mode privé  1.0
1                         NaN  NaN  Passage en mode public  0.0

but I need it to be as follows:

nbr de Kilomètres parcourus    2        
Nombre de reboot    0
Passage en mode privé  1.0
Passage en mode public  0.0

But it seems like python consider the dataframe with only one row as empty and I don't know why

df2: Empty DataFrame Columns: [nbr de Kilomètres parcourus, 3] Index: []

how can I append it in rows not in columns?

newbie
  • 646
  • 8
  • 27
  • Possible duplicate of [Pandas: append dataframe to another df](https://stackoverflow.com/questions/39815646/pandas-append-dataframe-to-another-df) – Amit Kumar Oct 03 '19 at 15:08
  • please copy and paste df1 and df2 here – ansev Oct 03 '19 at 15:10
  • df1: `Nombre de reboot 0` `0 Passage en mode privé 1` `1 Passage en mode public 3` df2: `Empty DataFrame` `Columns: [nbr de Kilomètres parcourus, 3]` `Index: []` – newbie Oct 03 '19 at 15:12
  • @AmitKumar sorry but I couldn't understand the code that you referred to or how is it related to my code – newbie Oct 03 '19 at 15:18
  • @AmitKumar I tried to run the code that u meantioned Iand I got an error: res = df[df['url'].str.contains(i)] TypeError: string indices must be integers – newbie Oct 03 '19 at 15:45

0 Answers0