Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions spark/sql/dataframe.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ type DataFrame interface {
Describe(ctx context.Context, cols ...string) DataFrame
// Distinct returns a new DataFrame containing the distinct rows in this DataFrame.
Distinct(ctx context.Context) DataFrame
// Dtypes returns the list of column names and their data types as a list of [name, type] pairs.
Dtypes(ctx context.Context) ([][2]string, error)
// Drop returns a new DataFrame that drops the specified list of columns.
Drop(ctx context.Context, columns ...column.Convertible) (DataFrame, error)
// DropByName returns a new DataFrame that drops the specified list of columns by name.
Expand Down Expand Up @@ -312,6 +314,18 @@ func (df *dataFrameImpl) Columns(ctx context.Context) ([]string, error) {
return columns, nil
}

func (df *dataFrameImpl) Dtypes(ctx context.Context) ([][2]string, error) {
schema, err := df.Schema(ctx)
if err != nil {
return nil, err
}
dtypes := make([][2]string, len(schema.Fields))
for i, field := range schema.Fields {
dtypes[i] = [2]string{field.Name, field.DataType.TypeName()}
}
return dtypes, nil
}

func (df *dataFrameImpl) Corr(ctx context.Context, col1, col2 string) (float64, error) {
return df.CorrWithMethod(ctx, col1, col2, "pearson")
}
Expand Down