[英]How to apply a function on pandas dataframe columns in parallel?
I have a pandas dataframe of 1million X 1000
dimension.我有一个1million X 1000
维的熊猫数据1million X 1000
。 Columns are categorical variables.列是分类变量。 I want to encode them.我想对它们进行编码。
I already got encodeing model from sklearn and fitted it.我已经从 sklearn 获得了编码模型并安装了它。 Now want to transform the columns of my dataframe in parallel.现在想要并行转换我的数据帧的列。
transformed_X = encoding_model.transform(X)
in the above X is my dataframe to be encoded.Here it does in serial manner.上面的 X 是我要编码的数据帧。这里它以串行方式进行。 Is there a way to apply the transform function in parallel to each column of my dataframe X?有没有办法将变换函数并行应用到我的数据框 X 的每一列?
如果您尝试对分类变量进行 1 热编码,则可以使用pd.get_dummies()函数
df = pd.get_dummies(df)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.