pandas-best-practices
Skill275 starsChanged 54 days agoApache-2.0View on GitHub
Best practices for Pandas data manipulation, analysis, and DataFrame operations in Python
In this repository264 other files it gives its agents.
- accessibility-a11ySkill
- alpine-jsSkill
- analytics-data-analysisSkill
- android-developmentSkill
- angular-developmentSkill
- angularSkill
- anime-jsSkill
- anthropic-claude-developmentSkill
- api-developmentSkill
- apollo-graphqlSkill
- aspnet-coreSkill
- astroSkill
- auth0-authenticationSkill
- autogen-developmentSkill
- automl-hyperparameter-optimizationSkill
- aws-developmentSkill
- azureSkill
- backend-developmentSkill
- bash-scriptingSkill
- beautifulsoup-parsingSkill
- bitbucket-workflowSkill
- blazorSkill
- blender-python-addonSkill
- blockchainSkill
- bootstrapSkill
- business-central-developmentSkill
- cheerio-parsingSkill
- chrome-extension-developmentSkill
- ci-cd-best-practicesSkill
- clean-architectureSkill
- clean-codeSkill
- clerk-authenticationSkill
- cloudflare-developmentSkill
- computer-vision-opencvSkill
- convexSkill
- cppSkill
- c-sharpSkill
- cssSkill
- cypressSkill
- data-analysis-jupyterSkill
- data-analystSkill
- data-jupyter-pythonSkill
- deep-learning-pythonSkill
- deep-learning-pytorchSkill
- deep-learningSkill
- deno-typescriptSkill
- design-systemsSkill
- devopsSkill
- django-pythonSkill
- django-rest-api-developmentSkill
- dockerSkill
- dotnetSkill
- drizzle-ormSkill
- drupal-developmentSkill
- elasticsearch-best-practicesSkill
- electron-developmentSkill
- elixirSkill
- embedded-stm32Skill
- esbuild-bundlerSkill
- ethereumSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
48 rules. About 0 are common, 15 are distinctive, and 33 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈15
Distinctive · estimate
This author's own choices. Worth a look.
33
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Write concise, technical responses with accurate Python examples
- Distinctive: line 17
Use functional programming.
- Distinctive: line 18
Prefer vectorized operations over explicit loops
- Distinctive: line 19
Use descriptive variable names reflecting data content
- Distinctive: line 20
Follow PEP 8 style guidelines
- Very specific: line 24
Use pd.read_csv(), pd.read_excel(), pd.read_json() with appropriate parameters
- Very specific: line 26
Use parse_dates for automatic datetime parsing
- Very specific: line 28
Use chunksize for reading large files incrementally
- Very specific: line 32
Use .loc[] for label-based indexing
- Very specific: line 33
Use .iloc[] for integer position-based indexing
- Very specific: line 34
Avoid chained indexing (e.g., df['col'][0]) - use .loc or .iloc instead
- Very specific: line 35
Use boolean indexing for conditional selection: df[df['col'] > value]
- Very specific: line 36
Use .query() method for complex filtering conditions
- Distinctive: line 40
Prefer method chaining for data transformations when possible
- Very specific: line 41
Use .pipe() for applying custom functions in a chain
- Distinctive: line 43
Keep chains readable by breaking across multiple lines
- Very specific: line 49
Check for missing data with .isna() and .info()
- Very specific: line 51
Use pd.NA for nullable integer and boolean types
- Distinctive: line 52
Document decisions about missing data handling
- Very specific: line 58
Check for duplicates with .duplicated() and handle appropriately
- Very specific: line 59
Use .describe() for quick statistical overview
- Very specific: line 63
Use .astype() for explicit type conversion
- Very specific: line 64
Use pd.to_datetime() for date parsing
- Very specific: line 65
Use pd.to_numeric() with errors='coerce' for safe numeric conversion
- Very specific: line 72
Use .groupby() for efficient aggregation operations
- Distinctive: line 74
Use named aggregation for clearer output column names
- Very specific: line 75
Consider .transform() for broadcasting results back to original shape
- Very specific: line 79
Use .pivot_table() for multi-dimensional aggregation
- Very specific: line 80
Use .melt() to convert wide to long format
- Very specific: line 81
Use .pivot() to convert long to wide format
- Very specific: line 82
Use .stack() and .unstack() for hierarchical index manipulation
- Distinctive: line 88
Use categorical data types for low-cardinality strings
- Very specific: line 90
Use pd.eval() and .eval() for large expression evaluation
- Very specific: line 94
Use vectorized operations instead of .apply() with row-wise functions
- Distinctive: line 95
Prefer built-in aggregation functions over custom ones
- Very specific: line 96
Use .values or .to_numpy() for NumPy operations when faster
- Very specific: line 100
Avoid iterating with .iterrows() - use vectorized operations
- Distinctive: line 101
Don't modify DataFrames while iterating
- Distinctive: line 103
Avoid growing DataFrames row by row - collect in list and create once
- Very specific: line 107
Use DatetimeIndex for time series data
- Very specific: line 109
Use .shift() and .diff() for lag operations
- Very specific: line 110
Use .rolling() and .expanding() for window calculations
- Very specific: line 114
Use .merge() for SQL-style joins
- Very specific: line 116
Use validate parameter to check join cardinality
- Very specific: line 117
Use .concat() for stacking DataFrames
- Very specific: line 122
Use snake_case for column names when possible
- Distinctive: line 123
Document data sources and transformations
- Distinctive: line 124
Keep notebooks reproducible with clear cell execution order
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Pandas Best Practices
Expert guidelines for Pandas development, focusing on data manipulation, analysis, and efficient DataFrame operations.
Code Style and Structure
- Write concise, technical responses with accurate Python examples
- Prioritize reproducibility in data analysis workflows
- Use functional programming; avoid unnecessary classes
- Prefer vectorized operations over explicit loops
- Use descriptive variable names reflecting data content
- Follow PEP 8 style guidelines
DataFrame Creation and I/O
- Use
pd.read_csv(),pd.read_excel(),pd.read_json()with appropriate parameters - Specify
dtypeparameter to ensure correct data types on load - Use
parse_datesfor automatic datetime parsing - Set
index_colwhen the data has a natural index column - Use
chunksizefor reading large files incrementally
Data Selection
- Use
.loc[]for label-based indexing - Use
.iloc[]for integer position-based indexing - Avoid chained indexing (e.g.,
df['col'][0]) - use.locor.ilocinstead - Use boolean indexing for conditional selection:
df[df['col'] > value] - Use
.query()method for complex filtering conditions
Method Chaining
- Prefer method chaining for data transformations when possible
- Use
.pipe()for applying custom functions in a chain - Chain operations like
.assign(),.query(),.groupby(),.agg() - Keep chains readable by breaking across multiple lines
Data Cleaning and Validation
Missing Data
- Check for missing data with
.isna()and.info() - Handle missing data appropriately:
.fillna(),.dropna(), or imputation - Use
pd.NAfor nullable integer and boolean types - Document decisions about missing data handling
Data Quality Checks
- Implement data quality checks at the beginning of analysis
- Validate data types with
.dtypesand convert as needed - Check for duplicates with
.duplicated()and handle appropriately - Use
.describe()for quick statistical overview
Type Conversion
- Use
.astype()for explicit type conversion - Use
pd.to_datetime()for date parsing - Use
pd.to_numeric()witherrors='coerce'for safe numeric conversion - Utilize categorical data types for low-cardinality string columns
Grouping and Aggregation
GroupBy Operations
- Use
.groupby()for efficient aggregation operations - Specify aggregation functions with
.agg()for multiple operations - Use named aggregation for clearer output column names
- Consider
.transform()for broadcasting results back to original shape
Pivot Tables and Reshaping
- Use
.pivot_table()for multi-dimensional aggregation - Use
.melt()to convert wide to long format - Use
.pivot()to convert long to wide format - Use
.stack()and.unstack()for hierarchical index manipulation
Performance Optimization
Memory Efficiency
- Use categorical data types for low-cardinality strings
- Downcast numeric types when appropriate
- Use
pd.eval()and.eval()for large expression evaluation
Computation Speed
- Use vectorized operations instead of
.apply()with row-wise functions - Prefer built-in aggregation functions over custom ones
- Use
.valuesor.to_numpy()for NumPy operations when faster
Avoiding Common Pitfalls
- Avoid iterating with
.iterrows()- use vectorized operations - Don't modify DataFrames while iterating
- Be aware of SettingWithCopyWarning - use
.copy()when needed - Avoid growing DataFrames row by row - collect in list and create once
Time Series Operations
- Use
DatetimeIndexfor time series data - Leverage
.resample()for time-based aggregation - Use
.shift()and.diff()for lag operations - Use
.rolling()and.expanding()for window calculations
Merging and Joining
- Use
.merge()for SQL-style joins - Specify
howparameter: 'inner', 'outer', 'left', 'right' - Use
validateparameter to check join cardinality - Use
.concat()for stacking DataFrames
Key Conventions
- Import as
import pandas as pd - Use
snake_casefor column names when possible - Document data sources and transformations
- Keep notebooks reproducible with clear cell execution order
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

