Available Python Libraries
On this page
The Sandbox Python Environment
The Code Execution Python sandbox isn’t a bare-bones Python environment. It includes a set of preinstalled scientific and data analysis libraries. Knowing these libraries is essential to fully leverage Code Execution capabilities and understand what you can—and can’t—ask the model to do.
Core Libraries
NumPy — Numerical Computing
NumPy is the fundamental library for numerical computing in Python. In the sandbox, it enables:
- Multidimensional array operations
- Linear algebra (matrices, vectors, decompositions)
- Random number generation
- Fourier transforms
- Advanced mathematical functions
# The model can write and execute this type of code
import numpy as np
# Generate a random matrix and calculate its eigenvalues
matrix = np.random.randn(5, 5)
eigenvalues = np.linalg.eigvals(matrix)
Pandas — Data Manipulation
Pandas is the standard library for tabular data manipulation:
- Creating and transforming DataFrames
- Cleaning and preparing data
- Aggregations and grouping
- Descriptive statistics
- Pivot tables and join operations
import pandas as pd
# Analyze structured data
df = pd.DataFrame({
'product': ['A', 'B', 'C', 'A', 'B'],
'sales': [100, 150, 80, 120, 200],
'month': ['Jan', 'Jan', 'Jan', 'Feb', 'Feb']
})
resume = df.groupby('product')['sales'].agg(['mean', 'sum', 'count'])
Matplotlib — Visualization
Matplotlib lets you create charts and visualizations:
- Line, bar, and pie charts
- Histograms and distributions
- Multi-axis plots
- Advanced customization (colors, legends, annotations)
The model can generate charts, but displaying them depends on how you handle the response in your application.
SciPy — Scientific Computing
SciPy extends NumPy with advanced scientific features:
- Optimization and function minimization
- Interpolation and numerical integration
- Signal processing
- Advanced statistics (hypothesis testing, distributions)
- Solving differential equations
What You Can Request
With these libraries, the model can perform a wide range of tasks:
Mathematical Calculations
- Solving equations and systems of equations
- Matrix calculations and linear algebra
- Descriptive and inferential statistics
- Combinatorial analysis and probabilities
Data Analysis
- Cleaning and transforming datasets
- Aggregations and group statistics
- Anomaly detection and outliers
- Correlations and regressions
Financial Modeling
- Return and risk calculations (Sharpe, Sortino)
- Portfolio optimization
- Valuation models
- Monte Carlo simulations
Scientific Computing
- Solving differential equations
- Physical simulations
- Time series analysis
- Experimental data processing
What You Can’t Do
The sandbox doesn’t allow you to:
- Install new libraries (
pip installisn’t available) - Use machine learning libraries (no scikit-learn, TensorFlow, PyTorch)
- Access external APIs or the network
- Read files from your local system
If your use case requires libraries unavailable in the sandbox, you’ll need to run the generated code in your own Python environment.
Key Takeaways
- The sandbox includes NumPy, Pandas, Matplotlib, SciPy, and other common packages
- These libraries cover numerical computing, data analysis, visualization, and scientific computing
- No additional library installation is possible
- ML libraries (scikit-learn, TensorFlow) are not available
- The model automatically leverages the right library for the requested task