1

I have pandas data frame numbered from x1,x2....x100 with same columns.

I want to append them all using a for loop. How can i do that? I know how to append two dataframe but how to do it for 100 of them. The main problem here is how can i have a dynamic variable name.

I want to append the data frames not concat.

x=x1.append(x2) x=x.append(x3) and so on.

I want to this in a loop.

9
  • 1
    Are they in separate variables or inside a list? Why can't you just use pd.concat? Commented Nov 10, 2017 at 20:21
  • I want to append the data frames not concat. x=x1.append(x2) x=x.append(x3) and so on. Commented Nov 10, 2017 at 20:25
  • I understood what you want. I'm saying pd.concat will do that for you. What I'd like to know is how your dataframes are currently stored. Commented Nov 10, 2017 at 20:26
  • They are pandas.DataFrame . My Question is, Is there a way I can call the name of the dataframe dynamically? Like we can do that for a string : for i in range(0,100): Print "String" + str(i) Commented Nov 10, 2017 at 20:32
  • 1
    Doing this with globals would make the solution almost too easy, but I'm hoping there's a way to avoid that. When you are creating your dataframes, why can't you append the dataframes xi to a list? Why do you keep them in 100 separate variables? Commented Nov 10, 2017 at 20:38

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.