'Python add exception to function
I have writte the following function:
List=[1, 2, 3, 4]
def get_choice(DF4, column1):
m = {}
for v in DF4[column1].unique():
m[v] = input('Label for {} ='.format(v))
if m[v] not in List:
print("Incorrect input. Use 1, 2, 3, or 4")
m[v] = input('Label for{} ='.format(v))
DF4['Label'] = DF4[column1].map(m)
return DF4
This function asks me to create an input for each row from a column. However, what I would like to do is skip the input for a few rows based on the value of another column, say column 2.
Is there a way I can add this to my function? So say for example, if the value in column 2 == 10, I will not have to give input for that row.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
