处理NP。
我有一个变量“ date_0”,该变量对应于特定周期内的感染日期,并且我必须从上一个变量(date_0)使用日期条件(> = 33天)创建另一个变量“ date_1”。 “ date_0”和“ date_1”的格式为%y-%m-%d%h:%m:%s。 因此,基本上我应该执行这样的日期条件:
如果DF ['date_1]> = 33天,则df ['date_1] else df ['date_0']
,我这样做:
df ['date_1'] = np.Where(((df ['date_1']> = 33d),df ['date_1'],df ['date_o'])
,我也尝试:
<代码> df ['date_1'] = np.Where((DF ['date_1']。days&gt; = 33),df ['date_1'],df ['date_o'])
,我失败了请帮我吗?
I have a variable "date_0" which correspond to date of infection in a certain period, and I have to create another variable "date_1" from the previous variable (date_0) with a date condition (>= 33 days). "date_0" and "date_1" are in format %Y-%m-%d %H:%M:%S.
So basically I should do a date condition like this :
if df['date_1] >= 33 days then df['date_1] else df['date_0']
And I do this :
df['date_1']= np.where((df['date_1']>= 33d), df['date_1'],df['date_O'])
And I try also with this :
df['date_1']= np.where((df['date_1'].days>= 33), df['date_1'],df['date_O'])
But I failed can you help me please ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用相当于np.where的pandas。前任:
you can use the pandas equivalent to np.where. Ex: