1

I'm working with a dataframe that only contains two columns, one categorical Peril and one numerical Frequency. I am trying to create a bar chart but I keep getting an error:

AttributeError: 'str' object has no attribute 'get'

when I run the following line:

sns.catplot(data='df', x='Frequency', y='Peril', kind='bar')

I've successfully plotted using this code before. I even went back and tried it in the old file and it works fine. I was originally thinking that maybe Frequency was being stored as a string instead of an integer, but when I ran df.info() it returned

RangeIndex: 36 entries, 0 to 35
Data columns (total 2 columns):
Peril        36 non-null object
Frequency    36 non-null int64
dtypes: int64(1), object(1)
memory usage: 656.0+ bytes

Currently stuck on how to resolve this issue.

2
  • 7
    Check the difference between data='df' and data=df Commented Dec 7, 2019 at 12:54
  • Wow I feel dumb not realizing that, especially when I did it correctly before. Thank you! Commented Dec 8, 2019 at 1:53

1 Answer 1

4

Your dataframe variable is wrapped in quotes when it should not be. Remove the quotes and it should work.

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.