Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Функция проверяет значение в столбце, если оно отрицательное, то умножает на -1, если положительное. Изменёные значения функция сохраняет в список.
- def negativ_to_positiv(data, column):
- new_positiv_column = []
- negativ_counter = 0
- for row in data[column]:
- if row < 0:
- row *= -1
- new_positiv_column.append(row)
- negativ_counter += 1
- elif row >= 0:
- new_positiv_column.append(row)
- print('Заменено отрицательных значений в столбце', column,': ', negativ_counter)
- return new_positiv_column
- #Проверяем столбцы на наличие отрицательных значений
- positiv_days_employed = negativ_to_positiv(data, 'days_employed')
- positiv_children = negativ_to_positiv(data, 'children')
- positiv_dob_years = negativ_to_positiv(data, 'dob_years')
- positiv_total_income = negativ_to_positiv(data, 'total_income')
- positiv_education_id = negativ_to_positiv(data, 'education_id')
- positiv_family_status_id = negativ_to_positiv(data, 'family_status_id')
- positiv_debt = negativ_to_positiv(data, 'debt')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement