【问题标题】:how to find difference in dates in pandas dataframe in Azure ML如何在 Azure ML 中查找 pandas 数据框中的日期差异
【发布时间】:2016-06-08 08:02:16
【问题描述】:

Azure 是否使用其他语法来查找日期和时间的差异。

Azure 中缺少任何包。
如何在 Azure ML 中查找 pandas 数据框中的日期差异。
我在数据框中有 2 列,我必须找到两列的差异,并且必须保留在第三列中,问题是,这一切在 python IDE 中运行良好,但在 Microsoft Azure 中却没有。
我的日期格式:2015-09-25T01:45:34.372Z
我必须找到 df['days'] = df['a'] - df['b']
我已经尝试了 stackoverflow 上几乎所有可用的语法。
请帮忙

mylist = ['app_lastCommunicatedAt', 'app_installAt', 'installationId']


'def finding_dates(df, mylist):
        for i in mylist:
            if i == 'installationId':
                continue
            df[i] = [pd.to_datetime(e) for e in df[i]]
        df['days'] = abs((df[mylist[1]] - df[mylist[0]]).dt.days)
        return df'


当我调用此函数时,它给出错误并且不接受下面的行继续。
我还尝试了许多其他的事情,比如将日期转换为字符串等

【问题讨论】:

  • 如果没有示例数据、代码、所需输出以及当前代码的错误输出,无法回答
  • 提供了一些信息会帮助你回答吗?
  • 这可以很好地转换为熊猫中的TimestampIn [167]: 2015-09-25T01:45:34.372Z pd.to_datetime('2015-09-25T01:45:34.372Z') Out[167]: Timestamp('2015-09-25 01:45:34.372000') 转换后df['a'] = pd.to_datetime(df['a']) 你可以这样做df['days'] = (df['a'] - df['b']).dt.days
  • 这件事我在 python IDE 中完成并且它正在工作,但同样的事情在 Azure 中不起作用。
  • 你需要发布代码并解释它是如何不工作的

标签: python azure pandas machine-learning azure-machine-learning-studio


【解决方案1】:

根据我的经验,问题似乎是由您的代码没有dataframe_service 引起的,这表明函数对数据框进行了操作,请参阅https://github.com/Azure/Azure-MachineLearning-ClientLibrary-Python#dataframe_service。如果对装饰器@不熟悉,请看https://www.python.org/dev/peps/pep-0318/了解。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-03-29
    • 2018-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多