Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

I'm using python pandas data frame , I have a initial data frame say D. I extract two data frames from it like this:

A = D[D.label == k]

B = D[D.label != k]

then I change the label in A and B:

A.label = 1

B.label = -1

I want to combine A and B so I can have them as one data frame something like union. The order of the data not important , however when we sample A and B from D they retain their indexes from D.

1 Answer

0 votes
by (41.4k points)

Use the append method to combine two data frames in python pandas:

bigdata = data1.append(data2, ignore_index=True)

Browse Categories

...