通过
regex=True
dfl = dfl.replace('.*40.*', 'boat', regex=True)
细节
In [278]: dfl
Out[278]:
A B C D
0 -0.389710060851 0.864059364935 0.499405126285 0.457617711403
1 0.136417007517 -0.0650312534859 0.0745132664561 2.02466341236
2 0.842889708053 -0.370605269504 -0.626932398518 0.0440612725966
3 -0.403271275281 -1.37477622923 -0.499721883883 -1.55997893498
4 3.39420415568 0.152915014005 0.205876128883 -0.644183954321
In [279]: dfl = dfl.replace('.*40.*', 'boat', regex=True)
In [280]: dfl
Out[280]:
A B C D
0 -0.389710060851 boat boat boat
1 0.136417007517 -0.0650312534859 0.0745132664561 2.02466341236
2 0.842889708053 -0.370605269504 -0.626932398518 boat
3 boat -1.37477622923 -0.499721883883 -1.55997893498
4 3.39420415568 boat 0.205876128883 -0.644183954321