title: In DataFrame Pandas how can i filter a timedelta64 by days and chang the value to str?
body: <p>So currently I’m generating a xlsx from a table that is in MySql with a lot of columns but for this matter I only need one.
  I’m using pandas to generate that xlsx, I open the connection to the database and then I do this:</p>
  <pre><code>import pandas as pd
  
  sql ='Select *from bd.teste'
  df=pd.read_sql_query(sql,sql_con_obj.con)
  df.to_excel(“generated.xlsx”)
  </code></pre>
  <p>If I quickly then do this:</p>
  <pre><code>df.info()
  </code></pre>
  <p>I’m going to have this :</p>
  <pre><code>&lt;class 'pandas.core.frame.DataFrame'&gt;
  RangeIndex: 147 entries, 0 to 146
  Data columns (total 21 columns):
   #   Column               Non-Null Count  Dtype
  ---  ------               --------------  -----
   0   Number               147 non-null    object
   1   Date                 147 non-null    object
   ...
   20  IT                   147 non-null    object 
  dtypes: object(20)
  memory usage: 24.8+ KB
  
  </code></pre>
  <p>The only one that matters is the &quot;Date&quot; column. I then pass the column that is in dtype object to datetime with this:</p>
  <pre><code>df['Date']=pd.to_datetime(df.['Date'],dayfirst=&quot;True&quot;)
  </code></pre>
  <p>So now the Date is in datetime and its in this <a href="https://i.stack.imgur.com/2U8fA.png" rel="nofollow noreferrer">format</a></p>
  <p>And it shows in the df.info that is in datetime64[ns].
  I want to create a new column that is going to deduce my current time with the date and give me the days.</p>
  <pre><code>df[&quot;Difference&quot;]= pds.to_datetime(&quot;now&quot;) - df['Date']
  </code></pre>
  <p>So the table is created and the values on it do match the difference between the dates, the table generated is dtype timedelta64[ns]<a href="https://i.stack.imgur.com/WGBWH.png" rel="nofollow noreferrer">like this</a>.The big problem comes now. I want to filter the days that are &lt;7 or &gt;7 and be <a href="https://i.stack.imgur.com/UI8xg.png" rel="nofollow noreferrer">like this</a>.
  Any ideias how to do that ? I though of iterrows but i dont know how to do it...</p>