pandas 读取csv中的错误数据处理
Published on Aug. 22, 2023, 12:11 p.m.
import pandas as pd
df = pd.read_csv('path_to_file.csv',error_bad_lines=False)
虽然可以正常读取,有可能导致列名混乱,可以尝试以下代码进行修改
df.rename(columns={'two':'new_name'}, inplace=True)
Published on Aug. 22, 2023, 12:11 p.m.
import pandas as pd
df = pd.read_csv('path_to_file.csv',error_bad_lines=False)
虽然可以正常读取,有可能导致列名混乱,可以尝试以下代码进行修改
df.rename(columns={'two':'new_name'}, inplace=True)