📜  [已解决] Pandas TypeError: no numeric data to plot - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:20.235000             🧑  作者: Mango

代码示例1
# 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()