DataFrame obeject operation to use python library pandas


1.overview

this is python library pandas to output csv files.
how to use DataFrame object and replacement DataFrame index by dict.

2.sample

sample.py
import pandas as pd

input_csv_file_path = <input_csv_file_path>
output_csv_file_path = <output_csv_file_path> 


def no_list_to_multiple_list(no_list):
    return [index * 2 for index in no_list]


if __name__ == '__main__':
    input = pd.read_csv(filepath_or_buffer=input_csv_file_path , encoding='ms932', sep=',')
    no_list = csv_input['no'].values.tolist()
    multiple_list = [no_list_to_multiple_list(no_list) for _ in no_list]
    dic = dict(zip(no_list, multiple_list))
    input['no'].replace(dic, inplace=True)
    input.set_index(['index'], inplace=True)
    input.to_csv(output_csv_file_path)