Documentation
Learn how to use GPandas for data manipulation in Go
Welcome to the GPandas documentation. GPandas is a high-performance data manipulation and analysis library written in Go, inspired by Python's popular pandas library.
Architecture Overview
GPandas uses a columnar architecture for efficient data operations:
Quick Start
Install GPandas using go get:
go get github.com/apoplexi24/gpandasMinimal Example
package main
import (
"fmt"
"github.com/apoplexi24/gpandas"
)
func main() {
gp := gpandas.GoPandas{}
// Load data from CSV
df, err := gp.Read_csv("data.csv")
if err != nil {
panic(err)
}
// Display the DataFrame
fmt.Println(df.String())
}Requirements
| Requirement | Version |
|---|---|
| Go | 1.18 or above |
| Architecture | Any (amd64, arm64) |
GPandas requires Go version 1.18 or above due to its use of generics.
Core Features
Data Loading
| Feature | Function | Description |
|---|---|---|
| CSV Files | Read_csv() | Load CSV files with concurrent parsing |
| JSON | Read_json(), ToJSON() | Read and write records-oriented JSON |
| Excel | Read_excel(), ToExcel() | Read and write .xlsx spreadsheets |
| Parquet | Read_parquet(), ToParquet() | Read and write Parquet files |
| SQL Databases | Read_sql() | Query SQL Server, PostgreSQL, and more |
| Google BigQuery | From_gbq() | Query BigQuery tables directly |
| In-Memory | DataFrame() | Create DataFrames from Go data structures |
DataFrame Operations
| Feature | Methods | Description |
|---|---|---|
| Column Selection | Select(), SelectCol() | Extract specific columns |
| Renaming | Rename() | Rename columns while preserving order |
| Adding Columns | Assign(), AssignFunc(), Insert() | Add, compute, or insert columns |
| Filtering | Filter(), Where() | Subset rows by comparison or predicate |
| Membership & Range | Isin(), Between() | Subset rows by a set of values or a value range |
| Top N | Nlargest(), Nsmallest() | Take the n largest or smallest rows without a full sort |
| Transformation | Apply(), Map(), ApplyRow() | Transform values and derive columns |
| Arithmetic | Add(), Sub(), Mul(), Div(), AddScalar() | Element-wise arithmetic on columns and scalars |
| Comparison | Gt(), Lt(), Eq(), GtScalar() | Element-wise comparisons producing boolean columns |
| String Methods | Str().Lower(), Contains(), Len() | Vectorized string operations |
| Missing Data | FillNA(), DropNA(), IsNA() | Detect, fill, and drop null values |
| Deduplication | Unique(), Duplicated(), DropDuplicates() | Find distinct values and remove duplicates |
| Type Casting | AsType(), DTypes(), Info() | Convert column types and inspect structure |
| Statistics | Describe(), Mean(), ValueCounts() | Summarize and aggregate numeric data |
| Correlation | Corr(), Cov() | Pairwise correlation and covariance |
| Sampling | Sample(), Pipe() | Random sampling and method chaining |
| Grouping | GroupBy(), Agg() | Group rows and aggregate |
| Window | Rolling(), Shift(), CumSum() | Moving and cumulative operations |
| Reshaping | Stack(), Unstack(), PivotTable(), Melt() | Convert between wide and long |
| DateTime | ToDatetime(), Dt() | Parse dates and extract components |
| Categorical | AsCategorical(), Categories() | Memory-efficient repeated strings |
| Merging | Merge(), MergeOn() | Join DataFrames on one or more keys |
| Display | String() | Pretty-print DataFrame as table |
| Export | ToCSV() | Export to CSV file or string |
| Plotting | PlotBar(), PlotScatter(), PlotHistogram(), PlotHeatmap() | Generate interactive charts |
Indexing
| Type | Accessor | Description |
|---|---|---|
| Label-based | Loc() | Access by row labels and column names |
| Position-based | ILoc() | Access by integer positions |
| Index Management | SetIndex(), ResetIndex() | Custom row labels |
Documentation Guide
Explore the documentation to learn more about GPandas capabilities:
Getting Started
- Installation & Setup - Install GPandas and run your first program
Loading Data
- Loading CSV Files - Read CSV files into DataFrames
- JSON, Excel & Parquet I/O - Read and write JSON, Excel, and Parquet files
- SQL Integration - Connect to databases and BigQuery
Working with DataFrames
- Creating DataFrames - Build DataFrames from scratch
- DataFrame Operations - Select, rename, display, and export
- Adding Columns - Add, compute, and insert columns
- Filtering Data - Subset rows by comparison or predicate
- Membership, Range & Top-N - Subset rows by value set, range, or the n largest and smallest values
- Transforming Columns - Apply and map functions over columns
- Arithmetic & Comparison - Element-wise arithmetic and comparison across columns and scalars
- String Methods - Vectorized string operations on columns
- Handling Missing Data - Detect, fill, and drop null values
- Unique Values & Deduplication - Distinct values and duplicate removal
- Type Casting & Inspection - Convert column types and inspect structure
- Summary Statistics - Describe and aggregate numeric data
- Correlation, Sampling & Pipe - Correlation, covariance, sampling, and chaining
- Grouping & Aggregation - Group rows and aggregate
- Window Functions - Rolling, shift, and cumulative operations
- DateTime - Parse dates and extract components
- Categorical Data - Memory-efficient repeated-string columns
- Sorting Data - Order rows by values or index labels
- Pivot and Melt - Reshape data between wide and long formats
- Stacking & MultiIndex - Stack/unstack and composite indexes
- Merging Data - Join and combine DataFrames (one or more keys)
- Plotting Charts - Visualize data with bar, line, pie, scatter, histogram, and heatmap charts
Indexing & Selection
- Label-based Indexing (Loc) - Access data by labels
- Position-based Indexing (iLoc) - Access data by position
Core Types
- Series - The fundamental column type
Performance Highlights
GPandas is designed for speed:
- Columnar Storage: Efficient memory layout for analytical queries
- Concurrent CSV Parsing: Multi-core utilization for large files
- Zero-Copy Operations: Minimal data copying where possible
- Thread-Safe Series: RWMutex protection for concurrent access