close

[Solved] pandas DataFrame “no numeric data to plot”

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error pandas DataFrame “no numeric data to plot” in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How pandas DataFrame “no numeric data to plot” Error Occurs?

Today I get the following error pandas DataFrame “no numeric data to plot” in python.

How To Solve pandas DataFrame “no numeric data to plot” Error ?

  1. How To Solve pandas DataFrame “no numeric data to plot” Error ?

    To Solve pandas DataFrame “no numeric data to plot” Error To solve this you have to convert the particular column or columns you want to use to numeric. First let me create a simple dataframe with pandas and numpy to understand it better.

  2. pandas DataFrame “no numeric data to plot”

    To Solve pandas DataFrame “no numeric data to plot” Error To solve this you have to convert the particular column or columns you want to use to numeric. First let me create a simple dataframe with pandas and numpy to understand it better.

Solution 1

Try the following before plotting:

df=df.astype(float)

Solution 2

To solve this you have to convert the particular column or columns you want to use to numeric. First let me create a simple dataframe with pandas and numpy to understand it better.

#creating the dataframe

import pandas as pd
import numpy as np
details=[['kofi',30,'male',1.5],['ama',43,'female',2.5]]
pf=pd.DataFrame(np.array(details),[0,1],['name','age','sex','id'])

pf  #here i am calling the dataframe

   name age     sex   id
0  kofi  30    male  1.5
1   ama  43  female  2.5

#to make your plot work you need to convert the columns that have numbers into numeric
as seen below 

pf.id=pd.to_numeric(pf.id)
pf.age=pd.to_numeric(pf.age)

pf.plot.scatter(x='id',y='age')

#This should work perfectly

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read