Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Issue 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)
df[['points', 'runrate', 'wins']].plot()
plt.show()
Comment

[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()
Comment

PREVIOUS NEXT
Code Example
Python :: python indexing 
Python :: fast guess for divisible numbers between two numbers 
Python :: python directed graph 
Python :: get current worker id multiprocessing 
Python :: new line in jupyter notebook markdown 
Python :: django pointfield value format for fixtures 
Python :: django time cualtulate 
Python :: compare if 2 numbers are relatively equal 
Python :: Dist/Hist Plot Code in Seaborn 
Python :: how to delete a row based on a criteria in python datafram 
Python :: Python Print Variable Using comma , character to separate the variables in a print statement 
Python :: django send_mail not working in testcase 
Python :: label default text value python 
Python :: argmax change dafault value for multiple maxima 
Python :: omr sheet python stackoverflow 
Python :: pandas convert text duration to minutes 
Python :: num = [7,8, 120, 25, 44, 20, 27] newnum = [] def remove_even(num): for i in num: if i%2 != 0: newnum.append(i) return newnum print("get_unevens") test(remove_even(num), [7,25,27]) 
Python :: vectorindexer pyspark 
Python :: tcs question 
Python :: add halt for 10 seconds in selenium python 
Python :: crop image using opencv with height and width 
Python :: spacegoat meaning 
Python :: cv2 leave only the biggest blob 
Python :: pyspark pivot max aggregation 
Python :: convert c code to python code online 
Python :: convert from python code to c++ code 
Python :: django froms 
Python :: how to change directory in python 
Python :: python hide terminal 
Python :: read bin file python 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =