spencersmith
spencersmith

Reputation: 3

How to get data from labeled row in multiple excel sheet tabs using python

enter image description hereI am trying to get a specific set of rows from 30 different excel tabs that are labeled by a date in column 1 of each excel tab. There are rows with the same date but are different in each tab. For example, I want the three columns of data in the same row of the row labeled '2019-08-08' from every tab and put it in a separate excel file.

import pandas as pd

df = pd.read_excel('mouse.xlsx', sheet_name=None, skiprows=5)

for name, sheet in df.items():

     sheet['sheet'] = name

Sunday = '2019-08-08'

sheet.loc(Sunday)

When I run sheet.loc, python is unable to find any data on 'sheet'

Upvotes: 0

Views: 368

Answers (1)

M_S_N
M_S_N

Reputation: 2810

IIUC, use

df.loc[df['Date'] == '2019-08-08']

Pass sunday as a variable not string

Upvotes: 1

Related Questions