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 :: taking multiple input in python 
Python :: pandas dataframe scan column for values between numbers 
Python :: pipilika search engine 
Python :: replace nat with date pandas 
Python :: python find index of minimum in list 
Python :: python game engine 
Python :: python paramiko 
Python :: change selected option optionmenu tkinter 
Python :: add dir to path python 
Python :: pandas df row count 
Python :: completely uninstall python and all vritualenvs from mac 
Python :: replace values of pandas column 
Python :: python multiply list 
Python :: dataframe fill none 
Python :: Concatenate Item in list to strings 
Python :: how to use ggplot matplotlib 
Python :: python add list to dictionary in loop 
Python :: convert string to class name python 
Python :: how to print x in python 
Python :: how to set default user group in django 
Python :: how to convert types of variablesin python 
Python :: how to do element wise multiplication in numpy 
Python :: python file handling 
Python :: pandas transpose 
Python :: should i make tkinter in classes ? , Best way to structure a tkinter application? 
Python :: python currency 
Python :: how to write to the end of a file in python 
Python :: cv2.threshold binary 
Python :: dictionary to a dataframe pandas arrays must all be same length 
Python :: python calculate derivative of function 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =