try
AdoConnection1.BeginTrans;
----
----
query1.ExecSql;
AdoConnection1.CommitTrans;
except
AdoConnection1.RollbackTrans;
-----
// manage the exception after rollback
-----
end;
此处ser3 = Series(['USA','Mexico','Canada'],index = ['0','5','10'])
在iPython中使用转发填充时出现错误
ranger = range(15)
ser3.reindex(ranger,method = 'ffill')
答案 0 :(得分:3)
正如大卫所说,这是由于索引是一个字符串。但是,为什么你得到“索引不单调错误”,答案是 - 为了重新索引方法,你的索引必须是有序/单调/递增的顺序。当你的索引是一个字符串时,它没有排序,正确的排序应该是:
ser3 =系列(['美国','墨西哥','加拿大'],索引= ['0','10','5']) ranger = range(15)
In [100]: ser3.reindex(ranger,method = 'ffill')
Out[100]:
0 NaN
1 NaN
2 NaN
3 NaN
4 NaN
5 NaN
6 NaN
7 NaN
8 NaN
9 NaN
10 NaN
11 NaN
12 NaN
13 NaN
14 NaN
dtype: object
希望这会有所帮助,并使reindex更清晰!!
答案 1 :(得分:0)
原始索引是字符串而不是数字。如果您将原始索引更改为数字(例如,index = [0,5,10]),它可以正常工作。
In [1]: from pandas import Series
...: ser3 = Series(['USA','Mexico','Canada'],index = [0,5,10])
...: ranger = range(15)
...: ser3.reindex(ranger,method = 'ffill')
...:
Out[1]:
0 USA
1 USA
2 USA
3 USA
4 USA
5 Mexico
6 Mexico
7 Mexico
8 Mexico
9 Mexico
10 Canada
11 Canada
12 Canada
13 Canada
14 Canada
dtype: object
答案 2 :(得分:0)
也许您可以尝试将ffill
l中的reindex
放入
ser3.reindex(ranger).ffill()