当前位置: 首页>>代码示例>>Python>>正文


Python Parser.getValueFromDf方法代码示例

本文整理汇总了Python中Parser.Parser.getValueFromDf方法的典型用法代码示例。如果您正苦于以下问题:Python Parser.getValueFromDf方法的具体用法?Python Parser.getValueFromDf怎么用?Python Parser.getValueFromDf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Parser.Parser的用法示例。


在下文中一共展示了Parser.getValueFromDf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: all

# 需要导入模块: from Parser import Parser [as 别名]
# 或者: from Parser.Parser import getValueFromDf [as 别名]
for fullpath in fullpaths:
    output = {}
    keyStats = {}
    regex = 'market_time.....,\s(...)\s(..),\s(....)'
    ticker = p.getTickerFromFullPath(fullpath, 'forward/data/', '.html')
    forwardDate, _ = p.getDateFromMarketTime(fullpath)
    fwdUnixTime, date = p.getDateFromMarketTime(fullpath)

    # pull key stats from Yahoo screen
    for feature in p.features:
        value = p.searchSourceForFeature(fullpath, feature)
        value = p.cleanup(value)
        keyStats[feature] = value

    # Pull stock price and s&p adjusted close on date and forward date and clean missing values
    price = p.getValueFromDf(p.stock_df, ticker.upper(), p.oneYearAgo(fwdUnixTime))
    priceFwd = p.getValueFromDf(p.stock_df, ticker.upper(),forwardDate)

    sp500 = p.getValueFromDf(p.sp500_df, 'Adjusted Close', p.oneYearAgo(fwdUnixTime))
    sp500Fwd = p.getValueFromDf(p.sp500_df, 'Adjusted Close', forwardDate)

    # clean up
    p.setDefaultIfNone(price, fwdUnixTime)
    p.setDefaultIfNone(priceFwd, fwdUnixTime)
    p.setDefaultIfNone(sp500, fwdUnixTime)
    p.setDefaultIfNone(sp500Fwd, fwdUnixTime)

    # calculate returns and alphas
    stockReturn = p.getReturn(price, priceFwd)
    sp500Return = p.getReturn(sp500, sp500Fwd)
    if all([stockReturn, sp500Return]):
开发者ID:mstampfer,项目名称:Equities,代码行数:33,代码来源:YahooForward.py

示例2: all

# 需要导入模块: from Parser import Parser [as 别名]
# 或者: from Parser.Parser import getValueFromDf [as 别名]
output_df = pd.DataFrame()

for fullpath in fullpaths:
    output = {}
    keyStats = {}
    ticker = p.getTickerFromFullPath(fullpath, '_KeyStats/', '/.*')
    dateStamp, unixTime = p.getDateStampAndUnixTime(os.path.basename(fullpath))

    # pull key stats from Yahoo screen
    for feature in p.features:
        value = p.searchSourceForFeature(fullpath, feature)
        value = p.cleanup(value)
        keyStats[feature] = value

    # Pull stock price and s&p adjusted close on date and forward date and clean missing values
    price = p.getValueFromDf(p.stock_df, ticker.upper(), unixTime)
    priceIn1y = p.getValueFromDf(p.stock_df, ticker.upper(), p.oneYearLater(unixTime))

    sp500 = p.getValueFromDf(p.sp500_df, 'Adjusted Close', unixTime)
    sp500In1y = p.getValueFromDf(p.sp500_df, 'Adjusted Close', p.oneYearLater(unixTime))

    # clean up
    p.setDefaultIfNone(price, unixTime)
    p.setDefaultIfNone(priceIn1y, unixTime)
    p.setDefaultIfNone(sp500, unixTime)
    p.setDefaultIfNone(sp500In1y, unixTime)

    # calculate returns and alphas
    stockReturn = p.getReturn(price, priceIn1y)
    sp500Return = p.getReturn(sp500, sp500In1y)
    if all([stockReturn, sp500Return]):
开发者ID:mstampfer,项目名称:Equities,代码行数:33,代码来源:QuandlForward.py


注:本文中的Parser.Parser.getValueFromDf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。