프로그래밍/Python
[pandas] 데이터프레임 특정 열에 절대값 부여하기 pd.DataFrame Absolute value for specific column (abs)
판다스 데이터프레임 특정 열에 절대값 부여하는 방법 file[column] = file[column].abs() 아래와 같은 데이터프레임을 가지고 있을 때 import pandas as pd file = pd.DataFrame({'a': ['1','2','3', '4'], 'b': [1,2,3,4], 'c': [-0.1, 0.2, -0.3, 0.4], 'd': ['True', 'False', 'True', 'False'], 'e': [True, False, True, False], 'f': ['hello', 'world', 'wide', 'handsome'] }) 원하는 컬럼명 지정하여 절대값 씌우기! column = 'c' file[column] = file[column].abs()