> For the complete documentation index, see [llms.txt](https://visual-python.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://visual-python.gitbook.io/docs/data-analysis/7.-bind.md).

# 7. Bind

Concatenate or Merge DataFrames

<figure><img src="https://2909106259-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl07NBXgl5MbkBetObqPW%2Fuploads%2FyOFgmm6BPTMc6giKvYuo%2Fimage.png?alt=media&amp;token=89de7eb0-e57a-47c5-aba8-ea3325271f67" alt="" width="332"><figcaption></figcaption></figure>

1. Click ***Bind*** from the ***Data Analysis*** category.

<figure><img src="https://2909106259-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl07NBXgl5MbkBetObqPW%2Fuploads%2F66qZEu2aZ6LsLjxKxRYf%2Fimage.png?alt=media&amp;token=e5e412cd-be32-406a-9227-a9e290c76da6" alt="" width="465"><figcaption></figcaption></figure>

2. ***Bind type***: Select a bind type.
   1. ***Concat***: Concatenates dataframes in the row or column direction.
   2. ***Merge***: Merge two dataframes based on a common column.

***

### Concat

<figure><img src="https://2909106259-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl07NBXgl5MbkBetObqPW%2Fuploads%2FQQXJbLTqNkQv5iLEmBGH%2Fimage.png?alt=media&amp;token=f38c6e33-8a22-419a-a33c-063e87fdcded" alt="" width="446"><figcaption></figcaption></figure>

1. ***DataFrame***: Select the dataframes you want to combine.
2. ***Join***: Choose a join method.
   1. ***Outer***: When concatenating dataframes, unmatched indices are filled with NaNs.
   2. ***Inner***: Concatenate only data with matching indexes (non-matching data will be removed).
3. ***Axis***: Select the direction of the connection.
   1. ***Index***: Concatenates data in the row direction (vertical).
   2. ***Column***: Concatenate data in the column direction (horizontal).
4. ***Sort***: Choose whether you want to sort the indexes. Sorting is done in ascending order by index number, which may change the order of the data.
5. ***User Option***: You can add options beyond what Visual Python provides.
6. ***Allocate to***: Specify a variable name to assign to the result.
7. ***Reset Index***: Reset the index to specify a new default integer index.
8. ***Code View***: Preview the code that will be output.
9. ***Data View***: Preview the output that will be printed.
10. ***Run***: Print and run the code.

***

### Merge

<figure><img src="https://2909106259-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl07NBXgl5MbkBetObqPW%2Fuploads%2F4eZJve22DQADLW6ILei4%2Fimage.png?alt=media&amp;token=62221fe4-9dc2-41b0-9cda-a431bbd9013e" alt="" width="442"><figcaption></figcaption></figure>

* ***Merge*** two dataframes based on a standard column, creating two new columns for the values from each dataframe.

1. ***Left Data**, **Right Data***: Select the two dataframes you want to merge.
2. ***How***: Choose a merge method.
   1. ***Inner***: Merge based on common values in key columns, only common values will be kept.
   2. ***Outer***: Merge based on all rows in the key column, and values that are not common and do not exist in either dataframe will be filled with NaN.
   3. ***Left***: Merge based on all rows in the key column in the left dataframe.
   4. ***Right***: Merge based on all rows in the key column in the right dataframe.
   5. ***Cross***: Outputs all combinations of data, regardless of the value in the key column.
3. ***On***: Allows you to merge based on specific columns. The columns selected must exist in both dataframes in common.
4. ***Left on**, **Right on***: You can select the columns in both dataframes that you want to base the merge on, respectively.
5. ***Suffixes***: If you have columns with the same name other than the common key column, add a suffix to differentiate them.
6. ***User Option***: You can add options beyond what Visual Python provides.
7. ***Allocate to***: Specify a variable name to assign to the result.
8. ***Reset Index***: Reset the index to specify a new default integer index.
9. ***Code View***: Preview the code that will be output.
10. ***Data View***: Preview the output that will be printed.
11. ***Run***: Print and run the code.
