我想选择一个DataFrame列,迭代它并仅选择数字,并用'Unknow'替换包含字母和其他唱歌的数字。我尝试过isreal()方法,但它没有用。有没有办法在没有功能的情况下完成这项任务?
%matplotlib inline
%pylab inline
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
file = 'C:/Users/Сынкетру/Desktop/attacks.csv'
df = pd.read_csv(file, sep=',', encoding='ISO-8859-1')
df_clean = df.Age.dropna()
def age(number):
try:
number = df.isreal()
except ValueError:
number = 'Unknown'
map(age, df_clean)
print(d)