Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looping a function
#4
Thank you. This is working. But the columns are not appending to the original dataframe, as I can't add dataframe2 = dataframe.assign(month='').

So how can I append the new columns to the original dataframe and create a new copy?

def add_column_missing(dataframe):
    
    from calendar import month_name
    for month in month_name:
        if month not in list(dataframe):
              dataframe.assign(month='')
                
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