简体   繁体   English

如果行的开始日期在今天起 90 天内,我如何过滤掉行并将它们放置到 R 中的下个月的 1 号?

[英]How can I filter rows out if their start date is within 90 days from today and place them out until the 1st of the following month in R?

I am having difficulty finding the words to describe what I am searching for but will try.我很难找到描述我正在寻找的东西的词,但会尝试。 I would like to solve the following using R or Python (but preferably R).我想使用 R 或 Python(但最好是 R)解决以下问题。

I have a dataframe of employees with their employee ID, department, start date etc. I am looking to perform calculations for each employee but would like to ignore employees that have a start date within 90 days from today.我有一个包含员工 ID、部门、开始日期等的员工数据框。我希望为每个员工执行计算,但想忽略从今天起 90 天内开始日期的员工。 Additionally I would like for this employee to be left out of consideration until the 1st of the following month.此外,我希望在下个月 1 日之前不要考虑该员工。 So basically exclude employees until the 1st of the month following their 90th day after hire .所以基本上排除员工,直到他们雇用后第 90 天后的第 1 个月 I do not need to include only workdays for this project.我不需要只包括这个项目的工作日。

In the below example for a report ran on May 3, 2022 I would exclude ID (22222, 33333, 44444, 666666 88888, and 99999).在以下 2022 年 5 月 3 日运行的报告示例中,我将排除 ID(22222、33333、44444、666666 88888 和 99999)。

ID    |  Dept       |  Start Date |
11111 |  Sales      |  04/10/2015 |
22222 |  Field Tech |  04/30/2022 |
33333 |  Lab tech   |  02/10/2022 | 
44444 |  Sales      |  02/01/2022 |
55555 |  Proj. Man  |  01/01/2022 |
66666 |  Administr  |  05/05/1999 |
77777 |  Field Tech |  06/25/2015 |
88888 |  Administr  |  03/01/2022 |
99999 |  Lab tech   |  05/12/2022 |
your_data %>%
  mutate(`Start Date` = as.Date(`Start Date`, "%m/%d/%Y")) %>%
  filter(`Start Date` - Sys.Date() >= 90)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何过滤我的数据框以仅显示每个月的第一个工作日? - How can I filter my dataframe to only show the 1st business day of each month? 我如何抵消 Pandas dayofyear 所以开始日期是 10 月 1 日而不是 1 月 1 日? - How do I offset Pandas dayofyear so start date is 1st October not 1st January? 我怎样才能在一个月的第一天对 pandas DatetimeIndex 重新采样 - how can i resample a pandas DatetimeIndex by 1st of month 如何查找在 30 天内进行第二次购买的第一次购买日期? - How to find 1st Purchase date who made 2nd purchase within 30 days? 如何过滤出今天日期在计算日期范围内的对象? - How can I filter out objects where todays date falls within a range of a calculated date? 如何在pandas数据帧中过滤属于特定列的第1和第3四分位数的行? - How to filter rows that fall within 1st and 3rd quartile of a particular column in pandas dataframe? 如何确定是否选择了列表中的第 2 项或第 1 项? - How do I make a condition to find out if the 2nd or 1st item in a list was selected? 如果日期在不同日期的 2 天范围内,如何按日期过滤? - How to filter by date if it is within a range of 2 days from a different date? 如何从 R 或 Python 上带有特定单词列表的文本文件中过滤出句子? - How can I filter out sentences from a text file with specific word list on R or Python? 我如何在新行上显示 pandas 中 start_date 和 end_date 之间每个月的天数? - how can i have on a new line the number of days for each month between start_date and end_date in pandas?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM