Python node: More than one type in column. Found int and float

@sanderlenselink

You can try the following. I’ve tested it in Visual Studio Code, but don’t have KNIME with me at the moment to test it in the scripting node.

You need to read the documentation closely. Each function returns different data types and, therefore, they each require different checks and approaches for processing data into a format you can return to KNIME. In the case of the history method the returned object is a Pandas DataFrame, rather than a dictionary, containing the data requested. This object contains the open-close-high-low pricing for each data within the requested range. To return this data to knime you need to extract the data for each symbol, the closing prices, and the value of the price for each data in the data set. You need to create a triplet of symbol-date-value for each of the values returned to KNIME.

import pandas as pd
from yahooquery import Ticker

funds = ['fb', 'aapl', 'amzn', 'nflx', 'goog']

ticker_def = Ticker(funds, asynchronous=True)

ticker_responses = ticker_def.history(period='1mo', interval='1wk')

prices_from_response = list()

for symbol in funds:
    ticker_data = ticker_responses.get(symbol)
    if isinstance(ticker_data, pd.DataFrame):
        ticker_close = ticker_data["close"]
        for date, value in ticker_close.iteritems():
            record = {
                "symbol": symbol,
                "data": str(date),
                "value": value
            }
            prices_from_response.append(record)

output_table = pd.DataFrame(prices_from_response)

This should point you in the right direction.

DiaAzul