Skip to content

count and countDistinct kdocs #1301

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 3 commits into
base: master
Choose a base branch
from
Open

count and countDistinct kdocs #1301

wants to merge 3 commits into from

Conversation

AndreiKingsley
Copy link
Collaborator

@AndreiKingsley AndreiKingsley commented Jul 2, 2025

Closes #1276

@Jolanrensen Jolanrensen self-requested a review July 3, 2025 09:56

import org.jetbrains.kotlinx.dataframe.DataFrame

/**
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is duplicating [AccessApi.ExtensionPropertiesApi]. Could be fine if this adds more information, but then probably call this "ExtensionPropertiesInformation" or something and link from the other one to here.

*
* For more information, see: {@include [DocumentationUrls.ExtensionPropertiesApi]}
*/
internal interface ExtensionPropertiesAPIDocs
Copy link
Collaborator

Choose a reason for hiding this comment

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

camel casing

* allowing you to define a [Boolean] condition using the row's values,
* including through [extension properties][ExtensionPropertiesAPIDocs] for convenient access.
*/
internal interface RowFilterDescription
Copy link
Collaborator

Choose a reason for hiding this comment

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

*RowFilterDocs following our convention.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The file can be @file:ExcludeFromSources

Copy link
Collaborator

Choose a reason for hiding this comment

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

Somewhat duplicating the description at aliases.kt, but I think it's different enough

*
* For more information: {@include [DocumentationUrls.Count]}
*
* @return the number of columns in this row.
Copy link
Collaborator

Choose a reason for hiding this comment

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

@see columnCount maybe? since this is just an alias for that

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, it doesn't make sense to link to the documentation website, as that's only for counting rows.
I'd probably even just write this piece of KDoc on columnsCount and @include it here

/**
* Counts the number of elements in the current row that satisfy the given [predicate].
*
* For more information: {@include [DocumentationUrls.Count]}
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

*
* See also common [aggregate][Grouped.aggregate].
*
* For more information: {@include [DocumentationUrls.Count]}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Aside from here, there might also be more helpful information here https://kotlin.github.io/dataframe/groupby.html

* - common [aggregate][Pivot.aggregate].
* - [pivotCounts][DataFrame.pivotCounts] shortcut.
*
* For more information: {@include [DocumentationUrls.Count]}
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here, maybe also link to the pivot docs

* ```
*
* @return A [DataFrame] with [groupBy] rows and pivoted counts as columns matching the [predicate]..
*/
public inline fun <T> PivotGroupBy<T>.count(crossinline predicate: RowFilter<T>): DataFrame<T> =
aggregate {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you fix this strangely linted function? :) not sure what the 0 is doing down there

*
* ### This [countDistinct] overload
*/
internal interface CountDistinctDocs
Copy link
Collaborator

Choose a reason for hiding this comment

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

@ExcludeFromSources

public fun AnyFrame.countDistinct(): Int = countDistinct { all() }

/**
* Returns number of distinct combinations of values in selected [columns] in this [DataFrame].
Copy link
Collaborator

Choose a reason for hiding this comment

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

*[columns\] it links up incorrectly to a package and KoDEx replaces it with a fq name

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

Successfully merging this pull request may close these issues.

Add KDocs for count and countDisctinct functions
2 participants