pandas-best-practices
Skill266 starsChanged 10 months 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 12
Write concise, technical responses with accurate Python examples
- Distinctive: line 14
Use functional programming.
- Distinctive: line 15
Prefer vectorized operations over explicit loops
- Distinctive: line 16
Use descriptive variable names reflecting data content
- Distinctive: line 17
Follow PEP 8 style guidelines
- Very specific: line 21
Use pd.read_csv(), pd.read_excel(), pd.read_json() with appropriate parameters
- Very specific: line 23
Use parse_dates for automatic datetime parsing
- Very specific: line 25
Use chunksize for reading large files incrementally
- Very specific: line 29
Use .loc[] for label-based indexing
- Very specific: line 30
Use .iloc[] for integer position-based indexing
- Very specific: line 31
Avoid chained indexing (e.g., df['col'][0]) - use .loc or .iloc instead
- Very specific: line 32
Use boolean indexing for conditional selection: df[df['col'] > value]
- Very specific: line 33
Use .query() method for complex filtering conditions
- Distinctive: line 37
Prefer method chaining for data transformations when possible
- Very specific: line 38
Use .pipe() for applying custom functions in a chain
- Distinctive: line 40
Keep chains readable by breaking across multiple lines
- Very specific: line 46
Check for missing data with .isna() and .info()
- Very specific: line 48
Use pd.NA for nullable integer and boolean types
- Distinctive: line 49
Document decisions about missing data handling
- Very specific: line 55
Check for duplicates with .duplicated() and handle appropriately
- Very specific: line 56
Use .describe() for quick statistical overview
- Very specific: line 60
Use .astype() for explicit type conversion
- Very specific: line 61
Use pd.to_datetime() for date parsing
- Very specific: line 62
Use pd.to_numeric() with errors='coerce' for safe numeric conversion
- Very specific: line 69
Use .groupby() for efficient aggregation operations
- Distinctive: line 71
Use named aggregation for clearer output column names
- Very specific: line 72
Consider .transform() for broadcasting results back to original shape
- Very specific: line 76
Use .pivot_table() for multi-dimensional aggregation
- Very specific: line 77
Use .melt() to convert wide to long format
- Very specific: line 78
Use .pivot() to convert long to wide format
- Very specific: line 79
Use .stack() and .unstack() for hierarchical index manipulation
- Distinctive: line 85
Use categorical data types for low-cardinality strings
- Very specific: line 87
Use pd.eval() and .eval() for large expression evaluation
- Very specific: line 91
Use vectorized operations instead of .apply() with row-wise functions
- Distinctive: line 92
Prefer built-in aggregation functions over custom ones
- Very specific: line 93
Use .values or .to_numpy() for NumPy operations when faster
- Very specific: line 97
Avoid iterating with .iterrows() - use vectorized operations
- Distinctive: line 98
Don't modify DataFrames while iterating
- Distinctive: line 100
Avoid growing DataFrames row by row - collect in list and create once
- Very specific: line 104
Use DatetimeIndex for time series data
- Very specific: line 106
Use .shift() and .diff() for lag operations
- Very specific: line 107
Use .rolling() and .expanding() for window calculations
- Very specific: line 111
Use .merge() for SQL-style joins
- Very specific: line 113
Use validate parameter to check join cardinality
- Very specific: line 114
Use .concat() for stacking DataFrames
- Very specific: line 119
Use snake_case for column names when possible
- Distinctive: line 120
Document data sources and transformations
- Distinctive: line 121
Keep notebooks reproducible with clear cell execution order
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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.

