📜  pandas 读取 csv dtype 列表 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:40.265000             🧑  作者: Mango

代码示例1
from ast import literal_eval
df = pd.read_csv("in.csv",converters={"Col3": literal_eval})

# Or, if you are sure the format is the same for all strings, stripping and splitting will be a lot faster:
df = pd.read_csv("in.csv",converters={"Col3": lambda x: x.strip("[]").split(", ")})
# But you will end up with the strings wrapped in quotes