Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

[Solved] Pandas TypeError: no numeric data to plot

# import pandas library
import pandas as pd
import matplotlib.pyplot as plt

# create pandas DataFrame
df = pd.DataFrame({'team': ['India', 'South Africa', 'New Zealand', 'England'],
                   'points': ['10', '8', '3', '5'],
                   'runrate': ['0.5', '1.4', '2', '-0.6'],
                   'wins': ['5', '4', '2', '2']})

# print the data frame
print(df)

# convert the columns to numeric using astype() function
df['points']=df['points'].astype(float)
df['runrate']=df['runrate'].astype(float)
df['wins']=df['wins'].astype(float)

df[['points', 'runrate', 'wins']].plot()
plt.show()
Source by itsmycode.com #
 
PREVIOUS NEXT
Tagged: #Pandas #numeric #data #plot
ADD COMMENT
Topic
Name
9+2 =