From 4ffab3310be1914c6c4496eaa7230358296d383f Mon Sep 17 00:00:00 2001 From: Rahul Soni Date: Tue, 18 Dec 2018 08:57:14 +0530 Subject: [PATCH] Updated index.md in data-science-tools/pandas (#29575) Added information about functions like Concatenation, Joining & Merging. --- .../data-science-tools/pandas/index.md | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/guide/english/data-science-tools/pandas/index.md b/guide/english/data-science-tools/pandas/index.md index e432eec925..e3ab6a4705 100644 --- a/guide/english/data-science-tools/pandas/index.md +++ b/guide/english/data-science-tools/pandas/index.md @@ -113,6 +113,40 @@ import matplotlib matplotlib.style.use('ggplot') df['ColumnName'].plot.hist() ``` +## Concatenation + +Concatenation basically glues together DataFrames. Keep in mind that dimensions should match along the axis you are concatenating on. You can use **pd.concat** and pass in a list of DataFrames to concatenate together: + + +```python +pd.concat([df1,df2,df3]) +``` +## Merging + +The **merge** function allows you to merge DataFrames together using a similar logic as merging SQL Tables together. For example: + + +```python +pd.merge(left,right,how='inner',on='key') +``` +## Joining +Joining is a convenient method for combining the columns of two potentially differently-indexed DataFrames into a single result DataFrame. + + +```python +left = pd.DataFrame({'A': ['A0', 'A1', 'A2'], + 'B': ['B0', 'B1', 'B2']}, + index=['K0', 'K1', 'K2']) + +right = pd.DataFrame({'C': ['C0', 'C2', 'C3'], + 'D': ['D0', 'D2', 'D3']}, + index=['K0', 'K2', 'K3']) +``` + + +```python +left.join(right) +``` #### More Information: 1. [pandas](http://pandas.pydata.org/)