I've been struggling with making a new column stating weekend or not based on 'Day of Week' column. I am using the following code based off a previous Stack Overflow question.
weekday_classification = {
'Weekday': ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
'Weekend': ['Saturday', 'Sunday']
}
weekday_classification = {day: all_days for all_days, l in weekday_classification.items() for day in l}
df["Weekend"] = df['Day of Week'].map(weekday_classification)
df.head()
Though the above code produces the desired effect - I am getting a warning which states:
ipython-input-21-e273917f31f9:6: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead
What is a way to get around this, I have read the documentation which says how to make a new column, however this seems to be only for more simplistic column creations.
I'm still just dipping my toes in the sand with Python and data analysis, I'm happy to receive general feedback.