title: optimize a string query with pandas. large data
body: <p>I have a dataframe data, which has close to 4 millions rows. It is a list of cities on the world. I need to query the city name as fast as possible.</p>
  <p>I found out that one with 346ms via indexing the city name:</p>
  <blockquote>
  <p>d2=data.set_index(&quot;city&quot;,inplace=False)</p>
  <p>timeit d2.loc[['PARIS']]</p>
  <p>1 loop, best of 3: 346 ms per loop</p>
  </blockquote>
  <p>This is still much too slow. I wonder if with group-by I could achieve faster query (how to do such a query). Each city has around 10 rows in the dataframe (duplicate city).
  I searched several days and could not find a clear solution on the internet</p>
  <p>thank you</p>