pandas 0.13 read_excel new format

I'm working with pandas a few time ago. In 0.12 version, I read excel files using pandas.read_excel(filename, sheetname, index_col), the read file was in the next format, with the header in the first row:

   Date            2  3
   2008-01-26  283.7  8
   2008-02-26  323.1  8
   2008-03-26  270.7  2
   2008-04-26  353.6  2

Now, when I save a dataframe to an excel file, the header format changes, in the first row are the columns names, and in the second row the index name, as show in the next table:

                   2  3
   Date               
   2008-01-26  283.7  8
   2008-02-26  323.1  8
   2008-03-26  270.7  2
   2008-04-26  353.6  2

Finally, when I read the new excel file format (using excel_read function), it reads the second row as a data row, and not takes it as the name of the index.

                   2   3
   Date          NaN NaN    
   2008-01-26  283.7   8
   2008-02-26  323.1   8
   2008-03-26  270.7   2
   2008-04-26  353.6   2

Is there any new function that allows me to read this new file format, taking account that the first and second rows are the new header?

Thanks.

Answers


The DataFrame will be written in a way that tries to mimic the REPL output. One difference from 0.12.0 version is that the index_label will be placed in the second row instead of the first. You can get the previous behaviour by setting the merge_cells option in to_excel() to False:

df.to_excel('path_to_file.xlsx', index_label='label', merge_cells=False)

Thus your files will be stored in the same way as in version 0.12.00 and will not have problems with reading.

peace

little carpenter


Need Your Help

What is the ideal way to send a date parameter over a GET request in Play Framework?

java javascript datetime playframework get

I am new to Play Framework. I am able to send simple data types like string, integer etc directly via the request and access them in the Back end Java method.

Fire Async method on page load with AJAX

.net ajax asynchronous

I am using ASP.NET 2.0 with AJAX Extensions (1.0?) and am wondering if it is possible to call a method asynchronously and have the results populate on the page after it has been loaded.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.