Concatenating along with an axis

This is the first option. We'll use the pd.concat() method from the pandas library.

The code for combining the dataframes is as follows:

# Option 1
dfSE = pd.concat([df1SE, df2SE], ignore_index=True)
dfML = pd.concat([df1ML, df2ML], ignore_index=True)

df = pd.concat([dfML, dfSE], axis=1)
df

The code should be self-explanatory by now. We first concatenated the dataframes from the Software Engineering course and the Machine Learning course. Then, we concatenated the dataframes with axis=1 to place them side by side.

The output of the preceding code is as follows:

You probably noticed that the StudentID field is repeated. One hack that could be done afterward is to delete the repeated field. However, let's see the other alternatives. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.125.100