将带有已包装标头的Excel文件读入熊猫

时间:2018-10-29 10:06:36

标签: python excel pandas

我想将Excel工作表导入为数据框,并导出为csv。我需要对许多文件执行此操作。但是,所有文件的标题都安排在两行中。

因此,当我读取文件时,得到的标题分别为Air Charge Temp \n(Deg C)//contoh input var input = [ ["0001", "Mike", "London", "21/05/1989", "Reading"], ["0002", "Sara", "Manchester", "10/10/1992", "Swimming"], ["0003", "John", "Kansas", "25/12/1965", "Cooking"], ["0004", "Dave", "Nevada", "6/4/1970", "going to gym"] ]; var data = ["ID: ", "Name: ", "Birthday: ", "Hobby: "]; for(var i = 0 ; input[i] && input[i].length ? i < input[i].length : null ; i++) { console.log(data[0] + input[i][0]+ ',', data[1] + input[i][1]+ ',', data[2]+input[i][2] + ' '+ input[i][3]+ ',', data[3]+ input[i][4]); };,依此类推。

如何将这些文件读入不带'\ n'的数据框中?

1 个答案:

答案 0 :(得分:2)

我相信您需要str.replace

/* desired results :
 * bedroom
 * area
 * bed
 * type
 * price
*/