0
소수점 앞에 0을 포함하여 SPSS에서 CSV로 데이터를 내보내는 방법이 있습니까? 현재 ".41"이 있고 "0.41"을 내 CSV 파일로 내보내려고합니다.SPSS 데이터를 CSV로 내보낼 때 소수점 앞에 0 추가
의견이 있으십니까?
소수점 앞에 0을 포함하여 SPSS에서 CSV로 데이터를 내보내는 방법이 있습니까? 현재 ".41"이 있고 "0.41"을 내 CSV 파일로 내보내려고합니다.SPSS 데이터를 CSV로 내보낼 때 소수점 앞에 0 추가
의견이 있으십니까?
SPSS에서 직접 수행하기가 어렵습니다. 한 가지 가능한 대답은 python + pandas를 사용하는 것입니다.
import pandas as pd
def add_leading_zero_to_csv(path_to_csv_file):
# open the file
df_csv = pd.read_csv(path_to_csv_file)
# you can possibly specify the format of a column if needed
df_csv['specific_column'] = df_csv['specific_column'].map(lambda x: '%.2f' % x)
# save the file (with a precision of 3 for all the floats)
df_csv.to_csv(path_to_csv_file, index=False, float_format='%.3g')
"g"형식에 대한 추가 정보 : Format Specification Mini-Language.
부동 소수점 문제에주의하십시오 (예 : answer to this question 참조)