Python Forum
Bulk add column to dataframe - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Bulk add column to dataframe (/thread-29882.html)



Bulk add column to dataframe - sambanerjee - Sep-24-2020

Hi:

I am trying to add a few columns to a dataframe - here is the code


import import_ipynb
import talib
import numpy
import yfinance as yf
import datetime as dt
import time
from datetime import datetime, timedelta 
import sqlite3
import pandas
import numpy as np
conn = sqlite3.connect('Strategy_RSI_MACD_Data.db')
c = conn.cursor()

c.execute("select distinct Stock from Universe")
tickers = c.fetchall()   
for row in tickers:
    if row[0]:
        ticker_list.append(row[0])
stockdetails = []
stockdetails = yf.download(
        tickers = ticker_list,
        period = '6mo',
        interval = '1d',
        group_by = 'ticker',
        auto_adjust = False,
        prepost = False,
        threads = True,
        proxy = None)
df_ta = pandas.DataFrame(data = stockdetails['Adj Close'], dtype=numpy.float64)
stockdetails['RSI'] = df_ta.apply(lambda c: talib.RSI(c, timeperiod = 14))
the last line is throwing this error -- ValueError: Wrong number of items passed 505, placement implies 1
anyone who can help me please ?

Thanks


RE: Bulk add column to dataframe - sambanerjee - Sep-24-2020

Anyone ?!? Wall ... bueller ?