Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looping a function
#3
It's not clear for me what rows starting from #39 suppose to do.

If function returns something, control returns to the function caller. This means that after hitting first return function is done.

If you change dataframe you don't need to return anything.

I observe that there is no January + there are ways to express this logic in more DRY (Don't Repeat Yourself) style:

from calendar import month_name
for month in month_name:
    if month not in list(dataframe):
        dataframe.assign(month='')
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
Looping a function - by wendysling - May-09-2019, 07:14 PM
RE: Looping a function - by Gribouillis - May-09-2019, 07:49 PM
RE: Looping a function - by perfringo - May-09-2019, 07:52 PM
RE: Looping a function - by wendysling - May-09-2019, 09:53 PM

Forum Jump:

User Panel Messages

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