更新时间:2023-11-23 17:28:34
熊猫方式:
使用 pandas 读取文件并获取数据框.然后,您可以简单地使用 lower()
Read the file using pandas and get the dataframe. Then you can simply use lower()
import pandas as pd
def conversion(text):
return text.lower()
df = pd.read_csv(file_path)
df[column_name] = df[column_name].map(conversion)
甚至是一个班轮:
df[column_name] = df[column_name].apply(lambda x: x.lower()) # If you have nan or other non-string values, you may need to convert x to string first like str(x).lower()
然后,您可以使用 to_csv 函数