Pandas reading excel file with some dates missing

304 views Asked by At

I have an excel file:

Date        Time    Value
1-May-04    00:00   3.74618
1-May-04    00:15   3.58507
1-May-04    00:30   3.30998

I need to convert it to:

                    Value
Date
2004-05-01 0:00     3.74618
2004-05-01 0:15     3.58507
2004-05-01 0:30     3.30998

Normally I pass to pd.read_excel()

parse_dates = {'Date': ['Date','Time']}

and it works great, but in some files some Date entries are missing which confuses pandas Index. So I have to read the file without parsing dates/times, then remove the lines with empty Date:

frame = frame.loc[pd.notnull(frame.index)]

And then combine Date+Time manually, which is not very nice. Is it possible to drop lines without Date during read?

0

There are 0 answers