使用pandas把某一列的字符值轉換爲數字

使用map的方法就能夠實現把某一列的字符類型的值轉換爲數字。web class_mapping = {'A':0, 'B':1} data[class] = data[class].map(class_mapping) 首先定義一個字典,而後使用map方法就能夠把某一列的字符類型的值轉換爲數字。 以上就是對使用pandas把某一列的字符值轉換爲數字的認識。app
相關文章
相關標籤/搜索