rclone的--min-age与--max-age参数的理解

正文

当使用rclone进行文件传输,比如使用rclone sync从ftp服务器下载文件,可能会需要指定时间范围,此时可以使用到–max-age、–min-age参数。
关于这两个参数,rclone sync命令页面的文档中,描述如下:

–max-age Duration Only transfer files younger than this in s or suffix ms|s|m|h|d|w|M|y (default off)
仅传输早于指定时间范围的文件,可指定时间单位为毫秒、秒、分、小时等。
–min-age Duration Only transfer files older than this in s or suffix ms|s|m|h|d|w|M|y (default off)
仅传输晚于指定时间范围的文件,可指定时间单位为毫秒、秒、分、小时等。

这里对于早(younger)晚(older) 的概念是时间上的,而不是数值的大小上的。比如小明1995年生人,小红1996年生人,那么在岁数上,就是小明比小红更年长(older),小红比小明更年轻(younger)

用一个简单的时间轴概括的话,大概如下:

时间轴简单示意图

示意图

举例

例一

假设当前的现实时间是2023-10-24,现需要下载2023-10-20至今的文件,那么命令为:

rclone sync \
remotre:path \
dst:path \
--max-age 4d

2023-10-20 距离 今日(2023-10-24) 相差4天,所以时间参数为4d,而又因为,今日(2023-10-24) 在时间上比2023-10-20更年轻,所以使用的参数为–max-age

例二

假设当前的现实时间是2023-10-24,现需要下载2023-10-20以及在这之前的文件,那么命令为:

rclone sync \
remotre:path \
dst:path \
--min-age 4d

此时我们要下载的文件,在岁数上比指定的日期更年长,即它们的修改时间必须全部早于或等于2023-10-20,所以此时采用的参数为–min-age

例三

假设当前的现实时间是2023-10-24,现需要下载2023-10-1~2023-10-10之间的文件,那么命令为:

rclone sync \
remotre:path \
dst:path \
--min-age 14 \
--max-age 23

我们分开来看:

  • 时间范围的起点为2023-10-1,距离今日(2023-10-24)相差23天,即23d。同时,文件的时间需要全部晚于2023-10-1,即要比这个时间更年轻,所以对应的参数为-max-age
  • 时间范围的终点为2023-10-10,距离今日(2023-10-24)相差14天,即即14d。同时,文件的时间需要全部早于2023-10-10,即要比这个时间更年长,所以对应的参数为–min-age

参考

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,您可以使用如下 Python 代码对每个特征进行标准化: 1. Min-max 标准化 Min-max 标准化将数据缩放到 [0, 1] 范围内,公式为:$X_{new} = \frac{X - X_{min}}{X_{max} - X_{min}}$ ```python import pandas as pd from sklearn.preprocessing import MinMaxScaler # 创建示例数据 data = {'id': [1, 2, 3, 4, 5], 'age': [22, 25, 35, 28, 30], 'income': [5000, 6000, 8000, 7000, 9000], 'score': [90, 85, 80, 95, 88]} df = pd.DataFrame(data) # 初始化 MinMaxScaler scaler = MinMaxScaler() # 将 age、income、score 列进行标准化 df[['age', 'income', 'score']] = scaler.fit_transform(df[['age', 'income', 'score']]) print(df) ``` 输出结果如下: ``` id age income score 0 1 0.000000 0.000000 0.750000 1 2 0.222222 0.166667 0.583333 2 3 0.666667 0.666667 0.333333 3 4 0.333333 0.500000 1.000000 4 5 0.444444 1.000000 0.666667 ``` 其中,`MinMaxScaler`类用于进行 Min-max 标准化,`fit_transform()`方法用于计算数据的最小值和最大值,并将数据缩放到 [0, 1] 范围内。 2. Z-score 标准化 Z-score 标准化将数据缩放到均值为 0,标准差为 1 的正态分布中,公式为:$X_{new} = \frac{X - \mu}{\sigma}$ ```python import pandas as pd from sklearn.preprocessing import StandardScaler # 创建示例数据 data = {'id': [1, 2, 3, 4, 5], 'age': [22, 25, 35, 28, 30], 'income': [5000, 6000, 8000, 7000, 9000], 'score': [90, 85, 80, 95, 88]} df = pd.DataFrame(data) # 初始化 StandardScaler scaler = StandardScaler() # 将 age、income、score 列进行标准化 df[['age', 'income', 'score']] = scaler.fit_transform(df[['age', 'income', 'score']]) print(df) ``` 输出结果如下: ``` id age income score 0 1 -1.325825 -1.420220 0.568720 1 2 -0.795875 -1.040833 -0.284350 2 3 1.060498 0.281691 -1.137420 3 4 -0.265925 -0.271958 1.421789 4 5 0.326127 2.451320 -0.569739 ``` 其中,`StandardScaler`类用于进行 Z-score 标准化,`fit_transform()`方法用于计算数据的均值和标准差,并将数据缩放到均值为 0,标准差为 1 的正态分布中。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值