Skip to content

Create argmin.md #6534

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

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

Conversation

Captain-Arnab
Copy link
Contributor

@Captain-Arnab Captain-Arnab commented Apr 12, 2025

Description

Issue Solved

Type of Change

  • Adding a new entry
  • Editing an existing entry (fixing a typo, bug, issues, etc)
  • Updating the documentation

Checklist

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

@mamtawardhani mamtawardhani self-assigned this Apr 12, 2025
@mamtawardhani mamtawardhani added new entry New entry or entries numpy NumPy entries status: under review Issue or PR is currently being reviewed labels Apr 12, 2025
@mamtawardhani mamtawardhani linked an issue Apr 14, 2025 that may be closed by this pull request
3 tasks
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 Captain-Arnab@, thank you for contributing to Codecademy Docs, the entry is nicely written! 😄

I've suggested a few changes, could you please review and modify those at your earliest convenience? Thank you! 😃

Comment on lines +2 to +15
Title: '.argmin()'
Description: 'Finds the index of the minimum value in a NumPy array or along a specified axis.'

Subjects:
- 'Computer Science'
- 'Data Science'
Tags:
- 'Data Structures'
- 'Arrays'
- 'Functions'
- 'NumPy'
CatalogContent:
- 'learn-python-3'
- '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: '.argmin()'
Description: 'Finds the index of the minimum value in a NumPy array or along a specified axis.'
Subjects:
- 'Computer Science'
- 'Data Science'
Tags:
- 'Data Structures'
- 'Arrays'
- 'Functions'
- 'NumPy'
CatalogContent:
- 'learn-python-3'
- 'paths/data-science'
Title: '.argmin()'
Description: 'Finds the index of the minimum value in a NumPy array, either across the entire array or along a specified axis.'
Subjects:
- 'Computer Science'
- 'Data Science'
Tags:
- 'Arrays'
- 'Data Structures'
- 'Functions'
- 'NumPy'
CatalogContent:
- 'learn-python-3'
- 'paths/data-science'

- 'paths/data-science'
---

The **`.argmin()`** function in NumPy identifies the index of the smallest value in an array. When working with multi-dimensional arrays, it can also return the index position 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.

Suggested change
The **`.argmin()`** function in NumPy identifies the index of the smallest value in an array. When working with multi-dimensional arrays, it can also return the index position along a specified axis.
The **`.argmin()`** function in NumPy is used to find the index of the smallest value in a NumPy array. It works on both 1D and multi-dimensional arrays, and when an axis is specified, it returns the index of the minimum value along that axis.
This function is commonly used in data analysis and numerical computations to quickly locate the position of the lowest value in an array.

Comment on lines +28 to +30
- `a`: (Required) The input array containing values to evaluate.
- `axis`: (Optional) The axis along which to find the minimum. If not provided, the array is flattened before computation.
- `out`: (Optional) An alternative array to store the result. It must be the correct shape.
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
- `a`: (Required) The input array containing values to evaluate.
- `axis`: (Optional) The axis along which to find the minimum. If not provided, the array is flattened before computation.
- `out`: (Optional) An alternative array to store the result. It must be the correct shape.
- `a`: The input array containing values to evaluate.
- `axis` (Optional): The axis along which to find the index of the minimum value. If not specified, the array is flattened and the index of the global minimum is returned.
- `out` (Optional): An alternative array to store the result. It must have the appropriate shape and data type.

## Syntax

```pseudo
numpy.argmin(a, axis=None, out=None)
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
numpy.argmin(a, axis=None, out=None)
numpy.argmin(a, axis=None, out=None, keepdims=<no value>)


Below is an example of using `.argmin()` on a 2-dimensional array to find index positions of minimum values:

```python
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
```python
```py

print(np.argmin(arr, axis=1)) # Minimum indices along rows
```

**Output:**
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
**Output:**
This code produces the output as follows:


## Codebyte Example

In this Codebyte, we generate a 2D array with random integers and use `.argmin()` in different contexts:
Copy link
Collaborator

Choose a reason for hiding this comment

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

avoid using pronouns

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure will do the changes

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 - NumPy built-in functions: .argmin()
2 participants