Dataframe extracted from email, ValueError: Cannot index with multidimensional key

Question:

A dataframe extracted from email (email saved to local disk, ".msg"), that I am not able to read its content.

The dataframe extracted from email, when wrote to an Excel file, it looks like the screenshot.

It as extra lines on the front rows (#1, #2, #3) with grids. I’ve only worked with dataframe that normally has 1 top row (not sure if it’s called Header).

What’s wanted is to read the correspondent cells. For example, to get the First Name in the dataframe, I’ve tried:

first_name = df.loc[df['Field'] == 'First Name', 'Value'].iloc[0]
print (visitor_name)

It gives error:

ValueError: Cannot index with multidimensional key

How can I do with this type of dataframe? (Here is the saved Excel file, https://filetransfer.io/data-package/6nOhcLTc#link)

enter image description here

Asked By: Mark K

||

Answers:

Did the following:

df = pd.read_excel('Sample.xlsx', engine='openpyxl')
print(df[df['Field'] == 'First Name']['Value'])

Output

6    David

If an error occurs, use the link

pip3 install openpyxl

Answered By: inquirer
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.