我有一个从 .tsv 文件读取数据然后将其列转换为数组的代码。但是,当我尝试在 for 循环中使用这些数组时,它会显示“TypeError:列表索引必须是整数或切片,而不是 str”。我怎样才能解决这个问题?
这是我的代码:
import pandas as pd
import astropy.units as u
import astropy.coordinates as coord
column_names = ["#paper", "Object", "RA","Ra2","DEC","Dec2"]
"""data = pd.read_csv ("jwebb.tsv", sep = '\t')"""
data=pd.read_csv("jwebb.tsv", sep = '\t', names=column_names)
STARS=data.Object.to_list()
RA=data.RA.to_list()
DEC=data.DEC.to_list()
for i in STARS:
from astroquery.simbad import Simbad
result_table = Simbad.query_object(STARS[i], wildcard=True)
print(result_table)