-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Term Entry] Python:Pandas built-in-functions: .concat() #4814
base: main
Are you sure you want to change the base?
[Term Entry] Python:Pandas built-in-functions: .concat() #4814
Conversation
Hey @Liam-Dupeyron, please sign the CLA |
Hi Mamta,
I just signed the CLA.
Best,
Liam
…On Fri, Jun 21, 2024 at 6:09 PM Mamta Wardhani ***@***.***> wrote:
[image: CLA assistant check]
<https://cla-assistant.io/Codecademy/docs?pullRequest=4814> Thank you for
your submission! We really appreciate it. Like many open source projects,
we ask that you sign our Contributor License Agreement
<https://cla-assistant.io/Codecademy/docs?pullRequest=4814> before we can
accept your contribution.You have signed the CLA already but the status is
still pending? Let us recheck
<https://cla-assistant.io/check/Codecademy/docs?pullRequest=4814> it.
Hey @Liam-Dupeyron <https://github.com/Liam-Dupeyron>, please sign the CLA
—
Reply to this email directly, view it on GitHub
<#4814 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A2XRKWB6AFF2AG7AIQZCDGLZITFD3AVCNFSM6AAAAABJW5L2KGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBTGYZTMMJTGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
*Liam Dupeyron*
Data Science
University of California Berkeley | Class of 2025
***@***.*** | (909)-300-2032
|
updated the yarn.lock file
updated the term-entry file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Liam-Dupeyron thank you for contributing to the Codecademy Docs! The entry is well written!
I've suggested a few changes, could you please review and modify those at your earliest convenience? Feel free to discuss any concerns, thank you! 😃
--- | ||
Title: '.concat()' | ||
Description: 'Concatenates multiple Dataframes or Series along a particular axis' | ||
Subjects: # Please only use Subjects in the subjects.md file (https://github.com/Codecademy/docs/blob/main/documentation/subjects.md). If that list feels insufficient, feel free to create a new Subject and add it to subjects.md in your PR! | ||
- 'A subject name' | ||
- 'A second subject name' | ||
- 'An nth subject name' | ||
Tags: # Please only use Tags in the tags.md file (https://github.com/Codecademy/docs/blob/main/documentation/tags.md). If that list feels insufficient, feel free to create a new Tag and add it to tags.md in your PR! | ||
- 'Data Structures' | ||
- 'Functions' | ||
- 'Pandas' | ||
- 'CSV' | ||
- 'Data' | ||
CatalogContent: # Please use course/path landing page slugs, rather than linking to individual content items. If listing multiple items, please put the most relevant one first | ||
- 'learn-Data-Analysis-with-Pandas' | ||
- 'paths/data-science' | ||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--- | |
Title: '.concat()' | |
Description: 'Concatenates multiple Dataframes or Series along a particular axis' | |
Subjects: # Please only use Subjects in the subjects.md file (https://github.com/Codecademy/docs/blob/main/documentation/subjects.md). If that list feels insufficient, feel free to create a new Subject and add it to subjects.md in your PR! | |
- 'A subject name' | |
- 'A second subject name' | |
- 'An nth subject name' | |
Tags: # Please only use Tags in the tags.md file (https://github.com/Codecademy/docs/blob/main/documentation/tags.md). If that list feels insufficient, feel free to create a new Tag and add it to tags.md in your PR! | |
- 'Data Structures' | |
- 'Functions' | |
- 'Pandas' | |
- 'CSV' | |
- 'Data' | |
CatalogContent: # Please use course/path landing page slugs, rather than linking to individual content items. If listing multiple items, please put the most relevant one first | |
- 'learn-Data-Analysis-with-Pandas' | |
- 'paths/data-science' | |
--- | |
--- | |
Title: '.concat()' | |
Description: 'Concatenates multiple DataFrames or Series along a specified axis.' | |
Subjects: | |
- 'Computer Science' | |
- 'Data Science' | |
Tags: | |
- 'Data Structures' | |
- 'Functions' | |
- 'Pandas' | |
CatalogContent: | |
- 'learn-python-3' | |
- 'paths/computer-science' | |
- 'paths/data-science' | |
- 'paths/data-science-foundations' | |
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added relevant subjects and tags from the documents
- 'paths/data-science' | ||
--- | ||
|
||
The `.concat()` function is used to concatenate and combine multiple [`DataFrames`](https://www.codecademy.com/resources/docs/pandas/dataframe) or [`Series`] along a particular axis. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The `.concat()` function is used to concatenate and combine multiple [`DataFrames`](https://www.codecademy.com/resources/docs/pandas/dataframe) or [`Series`] along a particular axis. | |
The **`.concat()`** function is used to concatenate and combine multiple [`DataFrames`](https://www.codecademy.com/resources/docs/pandas/dataframe) or [`Series`] along a specified axis. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first instance of the term should be wrapped in bold
## Syntax | ||
|
||
```pseudo | ||
pandas.concat(objs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The syntax should include all the parameters from the documentation of the .concat()
method. I found out the following two:
pandas.concat(objs, axis=0, join='outer', ignore_index=False, keys=None, levels=None, names=None, verify_integrity=False, sort=False, copy=True)
pandas.concat(objs, axis, join, ignore_index, keys, levels, names, verify_integrity, sort, copy)
You can use either of them
The `objs` parameter is essential and must be specified. It represents the objects to be concatenated and can be a sequence or mapping of pandas Series or DataFrame objects. The objects should be passed as a sequence (like a list or tuple) or a mapping (like a dictionary). | ||
|
||
The rest of the parameters are listed below: | ||
|
||
| Parameter Name | Data Type | Usage | | ||
| :----------------: | :--------------------------------------------------: | -------------------------------------------------------------------------------------- | | ||
| `axis` | int (0 for rows, 1 for columns ), default 0 | Specifies the axis along which to concatenate the objects | | ||
| `join` | str (“outer” (default), “inner,” “left,” or “right”) | Determines how to handle indexes on other axes | | ||
| `ignore_index` | bool, default `False` | If `True`, it resets the index in the resulting DataFrame | | ||
| `keys` | sequence (list or tuple), default None | Lets you construct a hierarchical index using the provided keys as the outermost level | | ||
| `levels` | list of sequences, default None | Specific levels to use for constructing a MultiIndex if keys are provided | | ||
| `names` | list of str, default None | Names for the levels generated in the hierarchical index | | ||
| `verify_integrity` | bool, default `False` | If `True`, checks whether the new concatenated axis contains duplicates | | ||
| `sort` | bool, default `False` | If `True`, it sorts the resulting Series or Dataframe by the keys | | ||
| `copy` | bool, default `True` | If `False`, it avoids copying data unnecessarily | | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the parameters need to be described in the below format:
objs
: A sequence or mapping ofSeries
orDataFrame
objects. Can be a list of objects or a dictionary where the keys will be used for thekeys
parameter.axis
: Specifies the axis along which to concatenate the objects. The default value is 0.
And so on, so in this format describe the other parameters as well.
## Example | ||
|
||
```py | ||
import pandas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import pandas | |
import pandas as pd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since you are using the abbreviation pd in the code
A B | ||
0 1 2 | ||
1 3 4 | ||
0 5 6 | ||
1 7 8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output that I'm getting is somewhat different, could you please run the code and check again? The is the output I'm getting:
A B
0 1 3
1 2 4
0 5 7
1 6 8
|
||
``` | ||
|
||
The example will result in a new DataFrame is returned by concatenating df1 and df2 along the rows: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example will result in a new DataFrame is returned by concatenating df1 and df2 along the rows: | |
The example will result in a new `DataFrame` created by concatenating `df1` and `df2` along the rows. The output is as follows: |
@mamtawardhani I just pushed the updated concat.md file! Let me know if I should add any other changes! |
I just double-checked, and I need to add more changes to the Syntax section. I will be working on it |
I have finished my last revision of the file and pushed it. Let me know if there are any further changes I should add! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Liam-Dupeyron, just one last change required from my side, could you please add a ##Codebyte Example block at the end, with a runnable code?
It should not have any ouput block, just the code showing the use of the .concat()
method.
Let me know once you add that, thanks! 😃
Hi @mamtawardhani! I just added the Codebyte Example. Let me know if there is anything else I should add or correct if needed :). |
minor changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Liam-Dupeyron for the contribution, the entry looks good for a second round of review! 🚀
Sounds awesome! Thank you so much for your support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Liam-Dupeyron, I've suggested a few changes, please make them and let me know. Thank you!!
- 'paths/data-science' | ||
- 'learn-python-3' | ||
- 'paths/computer-science' | ||
- 'paths/data-science-foundations' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 'paths/data-science' | |
- 'learn-python-3' | |
- 'paths/computer-science' | |
- 'paths/data-science-foundations' | |
- 'paths/data-science' | |
- 'learn-python-3' | |
- 'paths/computer-science' | |
- 'paths/data-science-foundations' |
We prefer to keep 2 CatalogContent here:
- Free course
- Pro course/path
Can you modify it accordingly?
@@ -0,0 +1,77 @@ | |||
--- | |||
Title: '.concat()' | |||
Description: 'Concatenates multiple Dataframes or Series along a particular axis.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description: 'Concatenates multiple Dataframes or Series along a particular axis.' | |
Description: 'Concatenates multiple dataframes or series along a particular axis.' |
|
||
- `objs`: Denotes the objects to concatenate, which can be a sequence or mapping of pandas `Series` or `DataFrame` objects. It must be specified and can be passed as a list, tuple, dictionary, Series, or DataFrame. | ||
- `axis`: Specifies the axis along which to concatenate the objects. The default value is 0 for rows, while 1 represents columns. | ||
- `join`: Determines how to handle indexes on other axes. Options include "outer" (default), "inner," "left," or "right." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you recheck if the join
parameter supports "left" or "right" options?
- `levels`: Specific levels to use for constructing a MultiIndex if keys are provided. Default value is `None`. | ||
- `names`: Names for the levels generated in the hierarchical index. Default value is `None`. | ||
- `verify_integrity`: If `True`, checks whether the new concatenated axis contains duplicates. Default value is `False`. | ||
- `sort`: If `True`, sorts the resulting `Series` or `Dataframe` by the keys. Default value is `False`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sorts non-concatenation axis if it is not already aligned. Please recheck this too.
result = pd.concat([df1, df2], axis=1, keys = ['df1', 'df2']) | ||
|
||
print(result) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary space.
- `ignore_index`: If `True`, resets the index in the resulting DataFrame. The new axis will be labeled 0, ..., n-1. Default value is `False`. | ||
- `keys`: Constructs a hierarchical index using the provided keys as the outermost level. Default value is `None`. | ||
- `levels`: Specific levels to use for constructing a MultiIndex if keys are provided. Default value is `None`. | ||
- `names`: Names for the levels generated in the hierarchical index. Default value is `None`. | ||
- `verify_integrity`: If `True`, checks whether the new concatenated axis contains duplicates. Default value is `False`. | ||
- `sort`: If `True`, sorts the resulting `Series` or `Dataframe` by the keys. Default value is `False`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `ignore_index`: If `True`, resets the index in the resulting DataFrame. The new axis will be labeled 0, ..., n-1. Default value is `False`. | |
- `keys`: Constructs a hierarchical index using the provided keys as the outermost level. Default value is `None`. | |
- `levels`: Specific levels to use for constructing a MultiIndex if keys are provided. Default value is `None`. | |
- `names`: Names for the levels generated in the hierarchical index. Default value is `None`. | |
- `verify_integrity`: If `True`, checks whether the new concatenated axis contains duplicates. Default value is `False`. | |
- `sort`: If `True`, sorts the resulting `Series` or `Dataframe` by the keys. Default value is `False`. | |
- `ignore_index`: If `True`, reset the index in the resulting DataFrame. The new axis will be labeled 0, ..., n-1. The default value is `False`. | |
- `keys`: Constructs a hierarchical index using the provided keys as the outermost level. The default value is `None`. | |
- `levels`: Specific levels to use for constructing a MultiIndex if keys are provided. The default value is `None`. | |
- `names`: Names for the levels generated in the hierarchical index. The default value is `None`. | |
- `verify_integrity`: If `True`, checks whether the new concatenated axis contains duplicates. The default value is `False`. | |
- `sort`: If `True`, sorts the resulting `Series` or `Dataframe` by the keys. The default value is `False`. |
- `names`: Names for the levels generated in the hierarchical index. Default value is `None`. | ||
- `verify_integrity`: If `True`, checks whether the new concatenated axis contains duplicates. Default value is `False`. | ||
- `sort`: If `True`, sorts the resulting `Series` or `Dataframe` by the keys. Default value is `False`. | ||
- `copy`: If `False`, avoids copying data unnecessarily. Default value is `True`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `copy`: If `False`, avoids copying data unnecessarily. Default value is `True`. | |
- `copy`: If `False`, avoid copying data unnecessarily. The default value is `True`. |
- `objs`: Denotes the objects to concatenate, which can be a sequence or mapping of pandas `Series` or `DataFrame` objects. It must be specified and can be passed as a list, tuple, dictionary, Series, or DataFrame. | ||
- `axis`: Specifies the axis along which to concatenate the objects. The default value is 0 for rows, while 1 represents columns. | ||
- `join`: Determines how to handle indexes on other axes. Options include "outer" (default), "inner," "left," or "right." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `objs`: Denotes the objects to concatenate, which can be a sequence or mapping of pandas `Series` or `DataFrame` objects. It must be specified and can be passed as a list, tuple, dictionary, Series, or DataFrame. | |
- `axis`: Specifies the axis along which to concatenate the objects. The default value is 0 for rows, while 1 represents columns. | |
- `join`: Determines how to handle indexes on other axes. Options include "outer" (default), "inner," "left," or "right." | |
- `objs`: Denotes the objects to concatenate, which can be a sequence or mapping of pandas `Series` or `DataFrame` objects. It must be specified and can be passed as a list, tuple, dictionary, Series, or DataFrame. | |
- `axis`: Specifies the axis to concatenate the objects. The default value is 0 for rows, while 1 represents columns. | |
- `join`: Determines how to handle indexes on other axes. Options include "outer" (default), "inner," "left," or "right." |
Description
-Added the pandas.concat() function term for Python: Pandas
Issue Solved
-Closed Issue #4524
Type of Change
Checklist
main
branch.Issues Solved
section.