% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/verbs_filter.R
\name{rp_summarize}
\alias{rp_summarize}
\title{Summarize data using pandas}
\usage{
rp_summarize(.data, ..., .by = NULL, table_name = NULL, return.as = "result")
}
\arguments{
\item{.data}{An R data.frame or tibble.}

\item{...}{Named summary expressions (e.g., \code{avg_price = mean(price)}).
Supports \code{mean}, \code{median}, \code{sd}, \code{var}, \code{min}, \code{max}, \code{sum}, and \code{n()}.}

\item{.by}{A bare column name or \code{c(col1, col2)} to group by.}

\item{table_name}{An optional character string. If provided, the generated Python code will replace the internal dataframe name with this string (e.g., \code{"diamonds.query(...)"}). This is useful for seeing the exact, copy-pasteable Python code. Defaults to \code{NULL} (uses \code{"df"}).}

\item{return.as}{What to return: "result", "code", or "all".}
}
\value{
A \code{data.frame} with the summarized and grouped data.
}
\description{
Aggregates a data frame by one or more groups, applying summary functions.
It translates R's \code{dplyr::summarise} syntax into a pandas \verb{.groupby().agg()}
command.
}
\examples{
\donttest{
if (reticulate::py_available(initialize = TRUE) &&
    reticulate::py_module_available("pandas")) {
  
  # Summarize by one group
  rp_summarize(ggplot2::diamonds, 
               avg_price = mean(price), 
               .by = cut)
  
  # Summarize by multiple groups and multiple functions
  rp_summarize(ggplot2::diamonds, 
               avg_price = mean(price), 
               count = n(),
               .by = c(cut, color))
}
}
}
