user14296107
user14296107

Reputation: 15

Make Excel Cell value Variable in Python Using Pandas

I have looked for a while on this one but can't seem to find out how to pick a specific cell value in an excel worksheet and assign it to variable in python. I get a Traceback Error with the code below.

I have a number of work rules I want to assign as variables in python that are stored in an cells within an excel workhseet.

(work rules[4][2] is how I am trying to make the cell value into a variable.

Code:

work_rules = pd.read_excel(
    'D:\\Personal Files\\Technical Development\\PycharmProjects\\Call Center Headcount Model\\Call Center Work Rules.xlsx',
    sheet_name='Inputs')

historical_start_date = work_rules[4][2]

print(historical_start_date)

Upvotes: 0

Views: 455

Answers (1)

user14296107
user14296107

Reputation: 15

Found it: Use the iloc method on the excel object: work_rules.iloc(4, 2)

Upvotes: 1

Related Questions