Pandas Scikit Learn Guide
Cursor-Regel für saubere pandas- und scikit-learn-Workflows ohne typische ML-Fehler.
Cursor-Regel für saubere pandas- und scikit-learn-Workflows ohne typische ML-Fehler.
Original-Beschreibung der Autoren: Cursor rules for Pandas development with scikit-learn guide integration.
Die Regel
---
description: "Cursor rules for Pandas development with scikit-learn guide integration."
globs: **/*
alwaysApply: false
---
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.
So nutzt du sie
Die Regel kopieren (Button oben) oder als Datei herunterladen und im Projekt unter .cursor/rules/ ablegen — Cursor lädt sie beim nächsten Start automatisch. Ältere Cursor-Versionen lesen alternativ eine einzelne .cursorrules-Datei im Projektstamm; dort einfach den Regel-Text ohne den Kopfblock zwischen den ----Zeilen einfügen.
Der Regel-Text ist englisch — Cursor versteht ihn unabhängig von der Sprache, in der Sie mit dem Editor chatten.
Im Detail
Eine Cursor-Regel für Data-Science-Projekte mit pandas und scikit-learn: Sie gibt Leitlinien für saubere DataFrame-Operationen, sinnvolle Preprocessing-Pipelines, Vermeidung von Data Leakage bei Train/Test-Splits und nachvollziehbare Modellbewertung vor. Praktisch für alle, die mit Cursor Analyse- oder ML-Skripte schreiben lassen und dabei typische Fehler (z. B. Skalierung vor dem Split, ineffiziente Schleifen statt Vektoroperationen) vermeiden wollen. Gegenüber Ad-hoc-Prompts sorgt sie für konsistentere, reproduzierbare Ergebnisse über mehrere Sessions hinweg. Für Deep-Learning-Projekte mit PyTorch/TensorFlow bringt sie wenig, da sie klassisches ML-Tooling adressiert.
Praxis-Tipp
Beispiel-Prompt: „Baue eine scikit-learn-Pipeline, die fehlende Werte imputiert, skaliert und einen RandomForest trainiert“ – die Regel sorgt dafür, dass Cursor Leakage-Fallen vermeidet.
Lizenz & Quelle
- Lizenz: CC0 1.0
- Quelle: PatrickJS/awesome-cursorrules (GitHub)
Inhalt ansehen (pandas-scikit-learn-guide.mdc)
Lade …
Erfahrungen & Kommentare.
Funktioniert der Regel bei Ihnen? Tipps, Stolperfallen, Varianten — teilen Sie es mit der Community.
Lade Kommentare …
Passt dazu.
AI Agent Specialist
Cursor-Regel, die den KI-Editor auf diszipliniertes, spezialisiertes Agenten-Verhalten trimmt.
Alpha Skills Quant Factor Research
Cursor-Regel für quantitative Faktor-Recherche im Trading/Finance-Bereich — leitet die KI zu methodisch sauberer Analyse an.
Android Jetpack Compose
Cursor-Regel für Android-Entwicklung mit Jetpack Compose — sorgt für idiomatischen, deklarativen Kotlin-UI-Code.
