0
    import pandas as pandaimport
    
#tickers = ['nflx','goog','fb','amzn','aapl']
    
    nflx = pandaimport.read_csv('nflx.csv')
    goog = pandaimport.read_csv('goog.csv')
    fb   = pandaimport.read_csv('fb.csv')
    amzn = pandaimport.read_csv('amzn.csv')
    aapl = pandaimport.read_csv('aapl.csv')
    
    nflx['ticker'] = 'nflx'
    goog['ticker'] = 'goog'
    fb['ticker'] = 'fb'
    amzn['ticker'] = 'amzn'
    aapl['ticker'] = 'aapl'


#for index in tickers:
#    index = pandaimport.read_csv('' + index + '.csv')
    
#for index in tickers:
#    @index['Address'] = address

How would I add 1 column to a string array of dataframes? I feel like all this should be done with a for loop...

Jon
  • 1
  • 1
  • 1
    You wouldn't have a list of dataframes after running this code, you aren't assigning the return of `read_csv()` to anything. Can you [edit] your sample code to make a [mcve]? – G. Anderson Nov 24 '20 at 23:56
  • updated code to the long version. I feel like I should be using a for loop or something more efficient – Jon Nov 25 '20 at 00:01

0 Answers0