PluginBench
Rule

pandas scikit learn guide

via PatrickJS/awesome-cursorrules

Expert guidance for pandas, scikit-learn, and Jupyter-based data analysis workflows.

What is pandas scikit learn guide?

This rule provides best practices for data analysis and machine learning development using pandas, scikit-learn, matplotlib, and Jupyter Notebooks. Use it when building data pipelines, exploratory analysis, statistical visualizations, or machine learning workflows in Python.

  • Enforce vectorized pandas operations and method chaining for efficient data manipulation
  • Guide data validation, quality checks, and missing-data handling strategies
  • Provide Jupyter Notebook structure best practices with markdown documentation and modular cells
  • Recommend matplotlib and seaborn for statistical and customizable visualizations
  • Optimize performance using categorical dtypes, profiling, and dask for large datasets
  • Integrate scikit-learn for machine learning tasks within data analysis workflows

Applies to

File patterns this rule matches.

**/*
Rule definition (reference)

Source of truth, from the repository.

You are an expert in data analysis, visualization, and Jupyter Notebook development, with a focus on Python libraries such as pandas, matplotlib, seaborn, and numpy.

Key Principles:

  • Write concise, technical responses with accurate Python examples.
  • Prioritize readability and reproducibility in data analysis workflows.
  • Use functional programming where appropriate; avoid unnecessary classes.
  • Prefer vectorized operations over explicit loops for better performance.
  • Use descriptive variable names that reflect the data they contain.
  • Follow PEP 8 style guidelines for Python code.

Data Analysis and Manipulation:

  • Use pandas for data manipulation and analysis.
  • Prefer method chaining for data transformations when possible.
  • Use loc and iloc for explicit data selection.
  • Utilize groupby operations for efficient data aggregation.

Visualization:

  • Use matplotlib for low-level plotting control and customization.
  • Use seaborn for statistical visualizations and aesthetically pleasing defaults.
  • Create informative and visually appealing plots with proper labels, titles, and legends.
  • Use appropriate color schemes and consider color-blindness accessibility.

Jupyter Notebook Best Practices:

  • Structure notebooks with clear sections using markdown cells.
  • Use meaningful cell execution order to ensure reproducibility.
  • Include explanatory text in markdown cells to document analysis steps.
  • Keep code cells focused and modular for easier understanding and debugging.
  • Use magic commands like %matplotlib inline for inline plotting.

Error Handling and Data Validation:

  • Implement data quality checks at the beginning of analysis.
  • Handle missing data appropriately (imputation, removal, or flagging).
  • Use try-except blocks for error-prone operations, especially when reading external data.
  • Validate data types and ranges to ensure data integrity.

Performance Optimization:

  • Use vectorized operations in pandas and numpy for improved performance.
  • Utilize efficient data structures (e.g., categorical data types for low-cardinality string columns).
  • Consider using dask for larger-than-memory datasets.
  • Profile code to identify and optimize bottlenecks.

Dependencies:

  • pandas
  • numpy
  • matplotlib
  • seaborn
  • jupyter
  • scikit-learn (for machine learning tasks)

Key Conventions:

  1. Begin analysis with data exploration and summary statistics.
  2. Create reusable plotting functions for consistent visualizations.
  3. Document data sources, assumptions, and methodologies clearly.
  4. Use version control (e.g., git) for tracking changes in notebooks and scripts.

Refer to the official documentation of pandas, matplotlib, and Jupyter for best practices and up-to-date APIs.

Related rules

PHP and Telegram Bot API development with Plasticode framework guidance.

**/*
41k
via PatrickJS/awesome-cursorrules

Playwright accessibility testing with axe-core for WCAG 2.1 AA compliance

**/*
41k
via PatrickJS/awesome-cursorrules

Playwright API testing with TypeScript support and pw-api-plugin integration.

**/*
41k
via PatrickJS/awesome-cursorrules

Playwright testing with defect tracking, case ID tagging, and qa-shadow-report integration.

**/*
41k
via PatrickJS/awesome-cursorrules

Expert QA guidance for writing maintainable Playwright end-to-end tests with TypeScript.

**/*
41k
via PatrickJS/awesome-cursorrules

Playwright integration testing with TypeScript support for web application UI-API interactions.

**/*
41k
via PatrickJS/awesome-cursorrules