Python Forum
How can I do it in Python for this SQL statement?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I do it in Python for this SQL statement?
#2
I think the following example should help you:

df = pd.DataFrame({'x': [3,3,0,0,0,1,2,1], 'y': [10,10,10,11,11,3,3,3], 'z':['a', 'a', 'a', 'a', 'b', 'b','b', 'b']})
df.groupby(['y', 'z']).x.min().reset_index()
Note, you should be sure that the datetime column is of 'date'-type (not a string).

Hope the following will work:
df.groupby(['NO', 'COURSE_YEAR'])['datetime'].min().reset_index()
Reply


Messages In This Thread
RE: How can I do it in Python for this SQL statement? - by scidam - Aug-24-2019, 03:15 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020