import numpy as np
import pandas as pd
data=pd.read_excel(r'DataScience.xls')
grouped=data.groupby(['class'])
print(grouped.sort_values(by=['week'],ascending=[False]))
Donât write your code like this
Write it using this `
(3 times) and end with `
(3 times)
Like this
Your code here
[squote=âZengcurry, post:1, topic:18193, full:trueâ]
import numpy as np
import pandas as pd
data=pd.read_excel(râDataScience.xlsâ)
grouped=data.groupby([âclassâ])
print(grouped.sort_values(by=[âweekâ],ascending=[False]))
[/quote]
Yes write it like this:
```py
# Your code here
```
1 Like
` start and end both with 3 times
1 Like
That works for small snippets but not for larger snippets with indentation
1 Like
Ok apart from that I can explain the error but try to fix it alone. grouped
is a grouped object, and sort_values()
method cannot be applied to it. Instead, it should be applied to the result of, for example, an aggregation function applied to the grouped object.
4 Likes