Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

IF Nested IF Pandas

$
0
0

enter image description here

Hello everyone i will insert and fill columns "Mark" info dataframe with IF statement, but in row Duration(Mins) = "10.0" the result is None, dtypes collumns Duration(Mins) is float64, thansk for your answer

import pandas as pd# Define data as a dictionarydata = {'Alarm Name': ['Cell Down', '4G Down', '3G Down', '2G Down', 'Cell Unavailable', 'Partial Down', 'Signalling Down'],'Duration(Mins)': [3, 5.9, 10.1, 2.9, -12, 6, 10]}#Functiondef mark(row):    if row['Duration(Mins)'] >= 0:        if row['Duration(Mins)'] < 3:            return '0-3 Mins'        elif row['Duration(Mins)'] < 6:            return '3-6 Mins'        elif row['Duration(Mins)'] < 10:            return '6-10 Mins'        elif row['Duration(Mins)'] > 10:            return '>10 Mins'    else:        return 'Open'df['Mark'] = df.apply(mark, axis=1)```

Viewing all articles
Browse latest Browse all 12111

Trending Articles