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

SNOW-1458133 Implement Index.value_counts #1902

Merged
merged 18 commits into from
Jul 26, 2024

Conversation

sfc-gh-vbudati
Copy link
Contributor

  1. Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-1458133

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
      • If this test skips Local Testing mode, I'm requesting review from @snowflakedb/local-testing
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am adding new credentials
    • I am adding a new dependency
    • If this is a new feature/behavior, I'm adding the Local Testing parity changes.
  3. Please describe how your code solves the related issue.

    Implemented Index.value_counts reusing the Series.value_counts implementation.

Examples:

>>> import pandas as pd
>>> idx = pd.Index(
...         [1, 2, 3, 2, 3, 5, 6, 7, 8, 4, 4, 5, 6, 7, 1, 2, 1, 2, 3, 4, 3, 4, 5, 6, 7]
...     )
>>> idx.value_counts()
2    4
3    4
4    4
1    3
5    3
6    3
7    3
8    1
Name: count, dtype: int64

@sfc-gh-vbudati sfc-gh-vbudati requested a review from a team as a code owner July 10, 2024 23:41
@sfc-gh-vbudati sfc-gh-vbudati changed the title SNOW-1458133 Index.value_counts SNOW-1458133 Implement Index.value_counts Jul 10, 2024
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
… change error from not implemented to assert
CHANGELOG.md Outdated Show resolved Hide resolved
@@ -1433,21 +1433,20 @@ def value_counts(
normalize: bool = False,
sort: bool = True,
ascending: bool = False,
bins: Any = None,
bins: int | None = 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
bins: int | None = None,
bins: Optional[int] = None,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The linter changes it to int | None whenever I use Optional

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@sfc-gh-joshi sfc-gh-joshi left a comment

Choose a reason for hiding this comment

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

one minor q

@@ -5,6 +5,8 @@ The following table is structured as follows: The first column contains the meth
The second column is a flag for whether or not there is an implementation in Snowpark for
the method in the left column.

Currently, there is no MultiIndex support.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean we don't support any operations on MultiIndex objects? We definitely do have APIs that return them, at least.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, we don't support any operations on MultiIndex since we don't have an object representing them. The lazy Index object we currently have is only supposed to be a single Index.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is still worth clarifying, since it might imply to users that DF/Series operations cannot return MultiIndex objects, even though they're just returning eager pandas.MultiIndex.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose I'll say that there is no lazy MultiIndex support. This Index object is supposed to only be a single Index but existing DataFrame and Series APIs may support native pandas MultiIndex operations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should be in now if you want to look at the text

@sfc-gh-vbudati sfc-gh-vbudati merged commit c88209f into main Jul 26, 2024
35 checks passed
@sfc-gh-vbudati sfc-gh-vbudati deleted the vbudati/SNOW-1458133-index-value-counts branch July 26, 2024 00:29
@github-actions github-actions bot locked and limited conversation to collaborators Jul 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants