0

I have a code using astroquery.Simbad to query star names. However Simbad working with names like "LP 944-20". However, the data contains names as "LP-944-20". How can i make code to ignore that first dash(hyphen)?

My code:

from astroquery.simbad import Simbad
result_table = Simbad.query_object("LP-944-20", wildcard=True)
print(result_table)
Machavity
  • 30,841
  • 27
  • 92
  • 100
Ege Tunç
  • 11
  • 4

1 Answers1

0

One simple approach would be to just replace the first hyphen with space:

inp = ["LP-944-20", "944-20", "20"]
output = [x.replace("-", " ", 1) for x in inp]
print(output)  # ['LP 944-20', '944 20', '20']
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360