-3
dic={'el1': [1,2,3], 'el2': 'Hello!'}
dic['el1']
x=str(100000)
time=170000000
sec='ALRS'
"SELECT * FROM order_log WHERE \"TIME\"<="+str(time)+" AND\"SECCODE\"='"+sec+"'"

import matplotlib.pyplot as plt
plt.plot(x['LOB'].index,x['LOB']['B'], x['LOB'].index,x['LOB']['S'])
# plt.bar(x['LOB'].index,x['LOB']['S'])

TypeError: string indices must be integers

why it is return string indices must be integers?

1 Answers1

0

Python requires that statements are nested so that it knows how the control flow is structured. The with block needs to know when to automatically close the file, so the next statement needs to be indented. Try this:

with open('C:/Users/Public/order_log.sql','r') as query:
    data=pd.read_sql_query(query.read(),conn) data.head(10)
alexyorke
  • 4,224
  • 3
  • 34
  • 55