小编use*_*503的帖子

R - 仅按时间的子集数据帧

我一直在寻找,但我仍然找不到按时间对数据帧进行子集化的方法,这里是示例数据:

 Duration            End Date          Start Date
      228 2013-01-03 09:10:00 2013-01-03 09:06:00
     1675 2013-01-04 17:34:00 2013-01-04 17:06:00
      393 2013-01-04 17:54:00 2013-01-04 17:48:00
      426 2013-01-04 11:10:00 2013-01-04 11:03:00
      827 2013-01-01 16:13:00 2013-01-01 15:59:00
      780 2013-01-01 16:13:00 2013-01-01 16:00:00
Run Code Online (Sandbox Code Playgroud)

结束日期和开始日期是POSIXct格式,如果我只在8:00到9:30之间的时间,这是我尝试过的.

tm1 <- as.POSIXct("08:00", format = "%H:%M")
tm2 <- as.POSIXct("09:30", format = "%H:%M")
df.time <- with(df, df[format('Start Date', '%H:%M')>= tm1 & format('End Date', '%H:%M')< tm2, ])
Run Code Online (Sandbox Code Playgroud)

但这会返回错误.我也试过这个,但它没有用.

df.time <- subset(df, format('Start Date', '%H:%M') >= '8:00' & format('End Date', '%H:%M') < '9:30'))
Run Code Online (Sandbox Code Playgroud)

如果有人告诉我我做错了什么?谢谢

r posixct

4
推荐指数
1
解决办法
2095
查看次数

Python PIL库-保存RGBA阵列中的图像

我目前正在使用PIL库来处理图像中的像素颜色。

我的问题是我不知道如何将rgba数组保存到png文件中。

image = Image.open(filepath)
pixels = image.load()
Run Code Online (Sandbox Code Playgroud)

...以像素为单位更改rgba值后,例如

pixels[2,10] = 30, 40, 50, 60
Run Code Online (Sandbox Code Playgroud)

然后,如果我尝试保存像这样的像素:

pixels.save(path)
Run Code Online (Sandbox Code Playgroud)

我得到错误

AttributeError: 'PixelAccess' object has no attribute 'save'
Run Code Online (Sandbox Code Playgroud)

然后如何将像素保存回png文件?

(很抱歉,如果这是一个愚蠢的问题)

谢谢!安德鲁

python png save python-imaging-library

2
推荐指数
1
解决办法
5744
查看次数

R - 从数据帧中的某个日期或时间段提取数据

我是R的新手,我有一个这样的数据框:

     EndDate EndId EndTime
1 02/01/2013   251   13:32
2 03/01/2013   251   17:19
3 04/01/2013   251   16:26
4 04/01/2013   368   08:36
5 05/01/2013   386   16:58
6 01/01/2013   329   11:51
Run Code Online (Sandbox Code Playgroud)

如何选择位于2013年3月1日至2013年1月5日之间的数据帧行?(或者在一段时间内?)谢谢

r

1
推荐指数
1
解决办法
4786
查看次数

标签 统计

r ×2

png ×1

posixct ×1

python ×1

python-imaging-library ×1

save ×1