I keep getting 'TableList' object has no attribute 'columns' in my code and I am not sure what that means in regards to it. How can I fix this?
This is using a gaia and 2 mass star database. I am trying to have the code scan through 2mass in regards to the gaia dataframe I already made and sort them accordingly through matches.
df = gaia_v2 #change to desired dataframe
twomass_matches = []
for i in range(0, len(df)):
result = Vizier(columns=["**"], catalog="II/246").query_region(SkyCoord(ra=df['ra'][i], dec=df['dec'][i],
unit=(u.deg, u.deg)), radius='20s')
if len(result) == 0:
values = [np.nan for i in range(0, 62)]
twomass_matches.append(values)
else:
result = result[0]
if len(result) == 1:
values = [result[colname][0] for colname in result.columns]
twomass_matches.append(values)
else:
diffs = [(((df['ra'][1]-result['RAJ2000'][j])**2)+(df['dec'][i]-result['DEJ2000'][j])**2) for j in range(0, len(result))]
index = diffs.index(min(diffs))
values = [result[colname][index] for colname in result.columns]
twomass_matches.append(values)
colnames = result.columns
for i in range(0, len(colnames)):
values = [twomass_matches[j][i] for j in range(0, len(twomass_matches))]
df[colnames[i]] = values
gaia_2mass = df
gaia_2mass.to_csv("2MASS_data") #insert desired filename to download as csv
print (gaia_2mass)
#full error is
AttributeError Traceback (most recent call last)
Cell In[53], line 21
18 values = [result[colname][index] for colname in result.columns]
19 twomass_matches.append(values)
---> 21 colnames = result.columns
22 for i in range(0, len(colnames)):
23 values = [twomass_matches[j][i] for j in range(0, len(twomass_matches))]
This is supposed to print a dataframe and then save it in a file.
My full error is