Facing error in visualization

Summary

UserWarning: I don’t know how to infer vegalite type from ‘empty’. Defaulting to nominal.
warnings.warn(
C:\Users\Laptop\anaconda3\lib\site-packages\altair\utils\core.py:219: UserWarning: I don’t know how to infer vegalite type from ‘empty’. Defaulting to nominal.
warnings.warn(

Steps to reproduce

Code snippet:

data = df["Country"].value_counts()

    fig1, ax1 = plt.subplots()
    ax1.pie(data, labels=data.index, autopct="%1.1f%%", shadow=True, startangle=90)
    ax1.axis("equal")  # Equal aspect ratio ensures that pie is drawn as a circle.

    st.write("""#### Number of Data from different countries""")
    st.pyplot(fig1)

    st.write("""#### Mean Salary Based On Country""")
    data_country = df.groupby(["Country"])["Salary"].mean().sort_values(ascending=True)
    st.bar_chart(data_country)

    st.write("""#### Mean Salary Based On Experience""")
    data_experience = df.groupby(["YearsCodePro"])["Salary"].mean().sort_values(ascending=True)
    st.line_chart(data_experience)

If applicable, please provide the steps we should take to reproduce the error or specified behavior.

Expected behavior:

Explain what you expect to happen when you run the code above.

Actual behavior:

Explain the undesired behavior or error you see when you run the code above.
If you’re seeing an error message, share the full contents of the error message here.

Debug info

  • Streamlit version: version 1.25.0
  • Python version: Python 3.10.9
  • OS version:
  • Browser version:

Requirements file

numpy

pandas

scikit-learn

streamlit

matplotlib

Links

  • Link to your GitHub repo:
  • Link to your deployed app:

Hi @Beblithe,

Thanks for posting! It seems the error is coming from the data where there is an “empty” value and Altair is defaulting it to “nominal” instead. Can you share or check your data to make sure it doesn’t contain “empty” or NaN values? You can always replace them using Pandas fillna or dropna.

Let me know if this helps.

@Beblithe if you have resolved the issue can you tell me , where to change to resolve this issue as am facing the same issue!!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.