<p>You can use <a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.append.html" rel="nofollow noreferrer">append</a> function:</p>

<pre><code>final = df1.append(df2, ignore_index=True)
</code></pre>

<p>To set the last column as labels, you set them as so by:</p>

<pre><code>labels = np.array(final["will_buy"])
</code></pre>

<p>So, when calling the <code>fit</code> method on the model you build, you set <code>labels = labels</code>.</p>

CC BY-SA 4.0
2019-11-15T11:57:53.850Z
2019-11-15T14:16:49.387Z
2019-11-15T14:16:49.387Z
serali
<p>I want to merge 2 data sets in one, but don't know the right approach to do it. The datasets are similar, the last column is the same - will or not them buy a product. In the first dataset, users who only will buy, in second - only who won't buy.   </p>

<p>The 1st dataset contains 500 rows and 2nd 10000 rows. What will be the right approach to merge it? How can I normalize them? And to point for an algorithm that the last column is the main sequence on what it should learn? </p>

<p>Example:</p>

<pre><code>id    income date will_buy

23123 200    10.5 Yes
</code></pre>

<p>and second dataset:</p>

<pre><code>id    income date will_buy

2323  100    10.5 No
</code></pre>

<datasets><data-preprocessing>
How can I merge two datasets?
干猕猴桃
# How can I merge two datasets?

(Asked by: username_0 on 2019-11-15)

I want to merge 2 data sets in one, but don't know the right approach to do it. The datasets are similar, the last column is the same - will or not them buy a product. In the first dataset, users who only will buy, in second - only who won't buy.   
The 1st dataset contains 500 rows and 2nd 10000 rows. What will be the right approach to merge it? How can I normalize them? And to point for an algorithm that the last column is the main sequence on what it should learn? 
Example:
id    income date will_buy

23123 200    10.5 Yes

and second dataset:
id    income date will_buy

2323  100    10.5 No

**Tags:** datasets, data-preprocessing


---

## 1 answers

### Answer by username_1 on 2019-11-15. Score: 1 | Accepted answer

You can use append function:
final = df1.append(df2, ignore_index=True)

To set the last column as labels, you set them as so by:
labels = np.array(final["will_buy"])

So, when calling the fit method on the model you build, you set labels = labels.


---

