Python Forum
TypeError: list indices must be integers or slices, not str
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: list indices must be integers or slices, not str
#3
Hi,
I have checked it with some GOOGL WIKI DATA SET from quandl.Run the following code...

import pandas as pd
df = pd.read_csv("C:\\Users\\Manas\\Desktop\\Misc\\WIKI-PRICES.csv") #.....(of course you have to change the path of your data set)
print(df.head())
df = df[['adj_open','adj_high','adj_low','adj_close','adj_volume']] #.....(Replace with your own features...Adj. Open etc)
df['HL_PCT'] = (df['adj_high'] - df['adj_low'])/df['adj_close']*100
df['PCT_change'] = (df['adj_close'] - df['adj_open']) / df['adj_open'] * 100.0
df = df[['adj_close', 'HL_PCT', 'PCT_change', 'adj_volume']]
print(df.head())
Reply


Messages In This Thread
RE: TypeError: list indices must be integers or slices, not str - by tapumanas - Mar-06-2018, 11:11 AM
Really need help with some code! - by TheDovah7 - Mar-05-2018, 05:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [pandas] TypeError: list indices must be integers or slices, not str but type is int. cspower 4 886 Dec-30-2023, 09:38 AM
Last Post: Gribouillis
  monthly composite of LST comes out incorrect, with error "mean of empty slices" ns423 1 2,892 Mar-18-2018, 06:40 PM
Last Post: ns423
  Making indices and rearrranging list reidybwoykeon 2 3,496 May-18-2017, 06:57 PM
Last Post: reidybwoykeon

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020