问题说明
想将numpy数据批量插入mysql,发现如下报错:
pymysql.err.ProgrammingError: nan can not be used with MySQL
替换方法
## data是numpy数据,格式入下:
data = [[nan, nan, '李幼斌', 'star'],
[nan, nan, '孟非', 'star']], dtype=object)
import pandas as pd
data[pd.isna(data)] = None # 将nan替换为None
data= data.tolist()