API Reference

seekwellpandas.methods.select(df, *columns)[source]

Select specific columns from the DataFrame, including negative selection.

Parameters: df (pd.DataFrame): The DataFrame to select columns from. *columns (str or list): The columns to select. Can be strings or lists.

Prefix column names with ‘-’ for negative selection.

Returns: pd.DataFrame: A DataFrame with the selected columns.

seekwellpandas.methods.where_(df, condition)[source]

Filter the DataFrame based on a condition.

Parameters: df (pd.DataFrame): The DataFrame to filter. condition (str): A string representing the condition in SQL-like syntax.

Returns: pd.DataFrame: A filtered DataFrame.

Examples: df.where_(‘A > 5’) df.where_(‘A in value1, value2, value3’) df.where_(‘A == value and B > 10’) df.where_(‘A in value1, value2 or B == value3 and C <= 10’)

seekwellpandas.methods.group_by(df, *columns)[source]

Group the DataFrame by specific columns.

Parameters: df (pd.DataFrame): The DataFrame to group. *columns (str or list): The columns to group by. Can be strings or lists.

Returns: pd.core.groupby.DataFrameGroupBy: A grouped DataFrame.

seekwellpandas.methods.having(df, condition)[source]

Filter groups in the DataFrame based on a condition.

Parameters: df (pd.core.groupby.GroupBy): The grouped DataFrame to filter. condition (str): The condition to filter by.

Returns: pd.DataFrame: A DataFrame with the filtered groups.

Raises: ValueError: If the DataFrame is not grouped.

seekwellpandas.methods.order_by(df, columns, ascending=True)[source]

Sort the DataFrame by specific columns.

Parameters: df (pd.DataFrame): The DataFrame to sort. *columns (str or list): The columns to sort by. Can be strings or lists. ascending (bool or list): Whether to sort in ascending order. Can be a single boolean or a list.

Returns: pd.DataFrame: A sorted DataFrame.

seekwellpandas.methods.limit(df, n)[source]

Limit the number of rows in the DataFrame.

Parameters: df (pd.DataFrame): The DataFrame to limit. n (int): The number of rows to return.

Returns: pd.DataFrame: A DataFrame with the limited number of rows.

seekwellpandas.methods.join_(df, other, on, how='inner')[source]

Join two DataFrames.

Parameters: df (pd.DataFrame): The first DataFrame. other (pd.DataFrame): The second DataFrame. on (str or list): The column(s) to join on. how (str): The type of join to perform. Default is ‘inner’.

Returns: pd.DataFrame: The joined DataFrame.

seekwellpandas.methods.union(df, other)[source]

Union two DataFrames.

Parameters: df (pd.DataFrame): The first DataFrame. other (pd.DataFrame): The second DataFrame.

Returns: pd.DataFrame: The union of the two DataFrames.

seekwellpandas.methods.distinct(df)[source]

Remove duplicate rows from the DataFrame.

Parameters: df (pd.DataFrame): The DataFrame to remove duplicates from.

Returns: pd.DataFrame: A DataFrame with duplicate rows removed.

seekwellpandas.methods.intersect(df, other)[source]

Intersect two DataFrames.

Parameters: df (pd.DataFrame): The first DataFrame. other (pd.DataFrame): The second DataFrame.

Returns: pd.DataFrame: The intersection of the two DataFrames.

seekwellpandas.methods.difference(df, other)[source]

Find the difference between two DataFrames.

Parameters: df (pd.DataFrame): The first DataFrame. other (pd.DataFrame): The second DataFrame.

Returns: pd.DataFrame: The difference between the two DataFrames.

seekwellpandas.methods.with_column(df, name, expression)[source]

Add a new column to the DataFrame based on an expression.

Parameters: df (pd.DataFrame): The DataFrame to add the column to. name (str): The name of the new column. expression (str): The expression to calculate the new column.

Returns: pd.DataFrame: The DataFrame with the new column added.

seekwellpandas.methods.rename_column(df, old_name, new_name)[source]

Rename a column in the DataFrame.

Parameters: df (pd.DataFrame): The DataFrame to rename the column in. old_name (str): The old name of the column. new_name (str): The new name of the column.

Returns: pd.DataFrame: The DataFrame with the renamed column.

seekwellpandas.methods.cast(df, column, dtype)[source]

Cast a column to a different data type.

Parameters: df (pd.DataFrame): The DataFrame to cast the column in. column (str): The column to cast. dtype (str or type): The data type to cast to.

Returns: pd.DataFrame: The DataFrame with the casted column.

seekwellpandas.methods.drop_column(df, *columns)[source]

Drop specific columns from the DataFrame.

Parameters: df (pd.DataFrame): The DataFrame to drop columns from. *columns (str): The columns to drop.

Returns: pd.DataFrame: A DataFrame with the specified columns dropped.

seekwellpandas.methods.unpivot(df, *args, **kwargs)[source]

Unpivot the DataFrame. This is a direct bridge to pandas’ melt function.

All arguments are passed directly to pandas.melt().

Parameters: df (pd.DataFrame): The DataFrame to unpivot. *args, **kwargs: Arguments to pass to pandas.melt().

Returns: pd.DataFrame: An unpivoted DataFrame.

See pandas.melt() documentation for full details on parameters: https://pandas.pydata.org/docs/reference/api/pandas.melt.html

seekwellpandas.methods.group_having(df, groupby_columns, having_condition)[source]