import numpy as np
import pandas as pd
import scipy.sparse as sparse
df = pd.Dataframe(np.arange(1,10).reshape(3,3))arr = sparse.coo_matrix(([1,1,1], ([0,1,2], [1,2,0])), shape=(3,3))df['newcol'] = arr.toarray().tolist()print(df)
产量
0 1 2 newcol0 1 2 3 [0, 1, 0]1 4 5 6 [0, 0, 1]2 7 8 9 [1, 0, 0]



