我正在重新采样数据框中的一些股票数据,这会导致一些 NaN 值。这是原始 Feed 的一部分:
In [34]: feeddf
Out[34]:
open high low close volume
date
2017-12-03 07:00:00 14.46 14.46 14.46 14.46 25000
2017-12-03 07:01:00 14.46 14.46 14.46 14.46 20917
2017-12-03 07:06:00 14.50 14.50 14.50 14.50 2000
2017-12-03 07:12:00 14.50 14.56 14.50 14.56 17000
Run Code Online (Sandbox Code Playgroud)
该提要应该是按分钟进行的,但是当没有可用数据时,该行将被跳过。当重新采样数据帧并聚合开盘价、最高价、最低价和收盘价时,它看起来像这样:
In [35]: feeddf.resample('3Min').agg({'open': 'first',
'high': 'max',
'low': 'min',
'close': 'last'})
Out[35]:
open high low close
date
2017-12-03 07:00:00 14.46 14.46 14.46 14.46
2017-12-03 07:03:00 NaN NaN NaN NaN
2017-12-03 07:06:00 14.50 14.50 14.50 14.50
2017-12-03 07:09:00 …Run Code Online (Sandbox Code Playgroud) #include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int main(int argc, char const *argv[])
{
struct stat buf;
int fd;
if (fd = open(argv[1], O_RDWR | O_CREAT)<0)
{
printf("file open error\n");
return 1;
}
if (link(argv[1], "link1") + link(argv[1], "link2")<0)
{
printf("error link\n");
return 1;
}
if (fstat(fd, &buf)<0)
{
printf("error fstat\n");
return 1;
}
printf("nlinks before = %d \n", buf.st_nlink);
if (unlink("link2") + unlink("link1") + unlink(argv[1])<0)
{
printf("unlink error\n");
return 1;
}
if (fstat(fd, &buf)<0)
{
printf("error fstat\n");
return …Run Code Online (Sandbox Code Playgroud)