#๐Ÿ”’ Trying to make a heatmap, but for counts of categorical variables

6 messages ยท Page 1 of 1 (latest)

sick pumiceBOT
#

@cinder tide

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

cinder tide
#

Code creating the dataset is as follows:

{python}
n_color_clarity=diamonds.groupby(["cut", "color", "clarity"]).agg(count=("cut", "count")).reset_index() # this resets the indices back to that of a normal dataset
print(n_color_clarity)
cinder tide
#

I settled on a stripplot, but now it's just a grid of points. Thus, I'm thinking of varying the size of the points based on the number of observations in said point (based on the count in the above dataframe). Here's what I've got so far:

g=sns.FacetGrid(n_color_clarity,col="cut")
g.map_dataframe(
    sns.stripplot,
    x="clarity",
    y="color",
    size="count"
)

Unfortunately, I keep getting an error that says:

TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'```
This is weird because `count` is an `int64`. What is wrong and how can I fix this?
#

This is the head of n_color_clarity btw:

   cut color clarity  count
0  Fair     D      I1      4
1  Fair     D      IF      3
2  Fair     D     SI1     58
3  Fair     D     SI2     56
4  Fair     D     VS1      5
sick pumiceBOT
#
Python help channel closed using Discord native close action

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.