Skip to content
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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

Liam-Dupeyron
Copy link

Description

-Added the pandas.concat() function term for Python: Pandas

Issue Solved

-Closed Issue #4524

Type of Change

  • Adding a new entry

Checklist

  • [ x] All writings are my own.
  • [ x] My entry follows the Codecademy Docs style guide.
  • [ x] My changes generate no new warnings.
  • [x ] I have performed a self-review of my own writing and code.
  • [ x] I have checked my entry and corrected any misspellings.
  • [ x] I have made corresponding changes to the documentation if needed.
  • [ x] I have confirmed my changes are not being pushed from my forked main branch.
  • [x ] I have confirmed that I'm pushing from a new branch named after the changes I'm making.
  • [x ] I have linked any issues that are relevant to this PR in the Issues Solved section.

@CLAassistant
Copy link

CLAassistant commented Jun 22, 2024

CLA assistant check
All committers have signed the CLA.

@mamtawardhani mamtawardhani self-assigned this Jun 22, 2024
@mamtawardhani
Copy link
Collaborator

CLA assistant check Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.You have signed the CLA already but the status is still pending? Let us recheck it.

Hey @Liam-Dupeyron, please sign the CLA

@Liam-Dupeyron
Copy link
Author

Liam-Dupeyron commented Jun 22, 2024 via email

@mamtawardhani mamtawardhani added python Python entries new entry New entry or entries status: under review Issue or PR is currently being reviewed labels Jun 22, 2024
updated the yarn.lock file
updated the term-entry file
Copy link
Collaborator

@mamtawardhani mamtawardhani left a 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! 😃

Comment on lines 1 to 17
---
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'
---
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
---
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'
---

Copy link
Collaborator

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Collaborator

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)
Copy link
Collaborator

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

Comment on lines 27 to 42
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 |

Copy link
Collaborator

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 of Series or DataFrame objects. Can be a list of objects or a dictionary where the keys will be used for the keys 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import pandas
import pandas as pd

Copy link
Collaborator

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

Comment on lines 59 to 63
A B
0 1 2
1 3 4
0 5 6
1 7 8
Copy link
Collaborator

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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:

@Liam-Dupeyron
Copy link
Author

@mamtawardhani I just pushed the updated concat.md file! Let me know if I should add any other changes!

@Liam-Dupeyron
Copy link
Author

I just double-checked, and I need to add more changes to the Syntax section. I will be working on it

@Liam-Dupeyron
Copy link
Author

I have finished my last revision of the file and pushed it. Let me know if there are any further changes I should add!

Copy link
Collaborator

@mamtawardhani mamtawardhani left a 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! 😃

@mamtawardhani mamtawardhani linked an issue Jun 24, 2024 that may be closed by this pull request
3 tasks
@Liam-Dupeyron
Copy link
Author

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
Copy link
Collaborator

@mamtawardhani mamtawardhani left a 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! 🚀

@Liam-Dupeyron
Copy link
Author

Sounds awesome! Thank you so much for your support

@avdhoottt avdhoottt self-assigned this Jun 28, 2024
@avdhoottt avdhoottt added status: under review Issue or PR is currently being reviewed and removed status: ready for next review labels Jun 28, 2024
Copy link
Collaborator

@avdhoottt avdhoottt left a 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!!

Comment on lines +12 to +15
- 'paths/data-science'
- 'learn-python-3'
- 'paths/computer-science'
- 'paths/data-science-foundations'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- '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.'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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."
Copy link
Collaborator

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`.
Copy link
Collaborator

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)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Unnecessary space.

Comment on lines +29 to +34
- `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`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `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`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `copy`: If `False`, avoids copying data unnecessarily. Default value is `True`.
- `copy`: If `False`, avoid copying data unnecessarily. The default value is `True`.

Comment on lines +26 to +28
- `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."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `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."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Term Entry] Python:Pandas built-in-functions concat
4 participants