我有一个像这样的DataFrame df
:
t pos
frame
0 2015-11-21 14:46:32.843517000 0.000000
1 NaT 0.000000
2 NaT 0.000000
3 NaT 0.000000
4 NaT 0.000000
5 NaT 0.000000
6 NaT 0.000000
7 NaT 0.000000
8 NaT 0.000000
9 NaT 0.000000
10 NaT 0.000000
11 NaT 0.000000
12 NaT 0.000000
13 NaT 0.000000
14 NaT 0.000000
15 NaT 0.000000
16 NaT 0.000000
17 NaT 0.000000
18 NaT 0.000000
19 NaT 0.000000
... ... ...
304 2015-11-21 14:46:54.255383750 12.951807
305 2015-11-21 14:46:54.312271250 5.421687
306 2015-11-21 14:46:54.343288000 3.614458
307 2015-11-21 14:46:54.445307000 1.204819
308 2015-11-21 14:46:54.477091000 0.000000
309 NaT 0.000000
310 NaT 0.000000
311 NaT 0.000000
312 NaT 0.000000
313 NaT 0.000000
314 2015-11-21 14:46:54.927361000 1.204819
315 2015-11-21 14:46:55.003917250 4.819277
316 2015-11-21 14:46:55.058081500 12.048193
317 2015-11-21 14:46:55.112070500 24.698795
318 2015-11-21 14:46:55.167366000 34.538153
319 2015-11-21 14:46:55.252116750 29.718876
320 2015-11-21 14:46:55.325177750 16.064257
321 2015-11-21 14:46:55.396772000 6.927711
322 2015-11-21 14:46:55.448250000 3.614458
323 2015-11-21 14:46:55.559872500 0.602410
我想用NaT
填充pandas.tslib.Timestamp
。
我找到了http://pandas.pydata.org/pandas-docs/version/0.17.0/generated/pandas.DataFrame.fillna.html
但我找不到method
。
但可能有一种解决方法。
答案 0 :(得分:3)
您对 XDocument doc = new XDocument();
XElement root = (XElement)doc.FirstNode;
string attribValue= "test";
var results = root.Descendants("Element").Where(x => x.Attribute("Attribute").Value == attribValue).ToList();
方法当前不使用interpolate
的看法是正确的。一种解决方案是将其转换为浮点数,对其进行插值并将其转换回Timestamp
:
Timestamp
然而,请注意,由于精度损失(我猜这可能是原因),数字有点偏离(加减去~1e-6秒)。明智的做法是只用内插值填充nan,并保持非nans的方式。