Reputation: 21
I have a code which reads data from .tsv file then turns its columns into arrays. However, when i try to use those arrays in for loop it says "TypeError: list indices must be integers or slices, not str". How can i fix this?
Here's my code:
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)
Upvotes: -1
Views: 63
Reputation: 130
A dataframe has no attribute called 'Object', 'RA', or 'DEC'. If those are columns you have to access them using:
Stars = data["Object"].to_list()
Upvotes: 0