【发布时间】:2015-01-09 17:38:12
【问题描述】:
我有以下数据框:
In [11]: import pandas as pd
In [12]: mydict = {'foo':[0, 0.3], 'bar':[1,0.55], 'qux': [0.3,4.1]}
In [13]: df = pd.DataFrame.from_dict(mydict, orient='index')
In [14]: df
Out[14]:
0 1
qux 0.3 4.10
foo 0.0 0.30
bar 1.0 0.55
我想要做的是将所有小于 1 的值替换为 0。 产量:
0 1
qux 0 4.10
foo 0 0
bar 1.0 0
我怎样才能做到这一点?
【问题讨论】: