title: How to resample Pandas data frame without grouping datetime in the result
body: <p>I'm trying to resample a data frame for <strong>last 30 seconds</strong> in <strong>Pandas</strong> in order to calculate <strong>OHLC</strong> of a candle stick.</p>
  <p>I'm using Pandas and SQLite.</p>
  <p>Data Structure is : _DateTime , _Price</p>
  <p>The Problem is when my last 30 seconds data belong to the different datetime(minute) the result will have more than 1 row !</p>
  <p><strong>My Code :</strong></p>
  <pre><code>con = sqlite3.connect('Pices.db')
  
  _Sql_Query : str = &quot;select _DateTime , _Price from _prices where datetime(_DateTime) &gt;= '&quot; + 
  datetime.strftime(datetime.now() - timedelta(seconds=30),&quot;%Y-%m-%d %H:%M:%S&quot;) + &quot;'&quot;
  
  df = pd.read_sql_query(_Sql_Query,con,parse_dates=True)
  
  con.close()
  
  df['_DateTime'] = pd.to_datetime(df['_DateTime'])
  
  df = df.resample('30S',on='_DateTime')['_Price'].ohlc().dropna()
  
  
  print(df)
  </code></pre>
  <p><strong>The Result :</strong></p>
  <pre><code>2020-11-28 10:03:30  5306000.0  5306000.0  5306000.0  5306000.0
  2020-11-28 10:04:00  5306000.0  5306000.0  5306000.0  5306000.0
  </code></pre>
  <p>Now , how can I resample just the <strong>Last 30 seconds</strong> of my data no matter what _DateTime it belongs to.</p>
  <p>I need to be just 1 row in the result of my Last 30 seconds.</p>
  <p>Best Regards.</p>