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)
Author And Source
この問題について(DataFrame obeject operation to use python library pandas), 我々は、より多くの情報をここで見つけました https://qiita.com/ckhaours/items/a5753843568762354f21著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .