Home > database >  Remove unamed:1 row from dataframe pandas
Remove unamed:1 row from dataframe pandas

Time:08-24

  • I am reading the csv as ldf_raw_data = pd.read_csv(lstr_file_path, index_col=0)
  • Dropping the na and using T to transpose it using ldf_raw_two = (ldf_raw_salary_slip.dropna()).T
  • But I am getting Unamed:1 as a multi-index. How can I remove it while performing transpose.
  • Reading CSV

enter image description here

  • After transpose

enter image description here

  • Expected output

enter image description here

  • Sample CSV
Salary Slip,
,
Employee Name,Aditi Aggarwal
Salary Period,June 2019
Employer Name,Hewlett Packard Enterprise

CodePudding user response:

It looks like your csv file contains some information you don't need.

You could try just to skip those rows by using keyword skiprows and header.

ldf_raw_data = pd.read_csv(lstr_file_path, index_col=0, skiprows=2, header=None).T

Source: enter image description here

  • Related