Created
July 29, 2016 18:06
-
-
Save ctufts/3d280f19f116eb17b924e9ff4976266f to your computer and use it in GitHub Desktop.
group by and apply a function with multiple input arguments (PANDAS)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ds has columns A, B, C, - group by A, then use B and C as inputs in the | |
# MSE calculation | |
grouped = ds.groupby('A') | |
mse = grouped.apply( lambda x: metrics.mean_squared_error(x['B'], x['C'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment