Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Panel data analysis with Python using linearmodels and pandas.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-10 | ✗→✓ | ▲ Improved | -8% | 0% |
| case-16 | ✗→✓ | ▲ Improved | 297% | 0% |
| case-06 | ✓→✓ | = Same ✓ | 77% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 31% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 62% | 0% |
This skill helps economists run panel data models in Python using pandas, statsmodels, and linearmodels, with correct fixed effects, clustering, and diagnostics.
Follow these steps to complete the task:
Before generating any code, ask the user:
Based on the context, generate Python code that:
pandaslinearmodels.PanelOLS or RandomEffectsAfter generating output:
python# ============================================ # Panel Data Analysis in Python # ============================================ import pandas as pd from linearmodels.panel import PanelOLS # Load data df = pd.read_csv("panel_data.csv") # Set panel index df = df.set_index(["firm_id", "year"]) # Create treatment indicator df["treat_post"] = df["treated"] * df["post"] # Two-way fixed effects model model = PanelOLS.from_formula( "outcome ~ 1 + treat_post + EntityEffects + TimeEffects", data=df ) results = model.fit(cov_type="clustered", cluster_entity=True) print(results.summary)
pandaslinearmodelsstatsmodelsInstall with:
bashpip install pandas linearmodels statsmodels
Other measured skills in the registry, with their headline benchmark lift.