Since this has the character of a command, I would probably format it close to your example, for example:
df.groupby[['x','y']] \ .apply(lambda x: np.max(x['z'])-np.min(x['z'])) \ .sort_values(ascending=False)
It took me a long time to realize that I could break these expressions before the dots, which is often more readable than breaking in parentheses (the same goes for βsome long string .format ()).
If it was more like evaluating an expression, I would have wrapped it all in parentheses, which are considered more "Pythonic" than line-continuation markers:
var = ( df.groupby[['x','y']] .apply( lambda x: np.max(x['z'])-np.min(x['z']) ) .sort_values(ascending=False) )
source share