1

I have data

      date               mail                 request
2016-06-17 13:27:49 [email protected]    GET HTTP/1.1
2016-06-17 13:30:46 [email protected]    GET HTTP/1.1
2016-06-17 12:05:04 [email protected]    GET HTTP/1.1
2016-06-17 12:05:28 [email protected]    GET HTTP/1.1
2016-06-17 12:18:36 [email protected]    GET HTTP/1.1

I need to create empty excel file with every name from mail and add to this sheet1, sheet2, sheet3, sheet4. I use

df.groupby('mail').apply(lambda g: g.to_excel(g.name + '.xlsx', u'sheet1'))

but it's creating files with data(I need in empty) and only sheet1 What I should do?

1 Answer 1

1

You're using g.to_excel which is supposed to put data in the file.

Instead, create an empty dataframe and use it with to_excel.

edf = pd.DataFrame()

f.groupby('mail').apply(lambda g: edf.to_excel(g.name + '.xlsx', u'sheet1'))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.