title: Filtering a dataframe according to user input values in python
body: <p>I need to write a script in python prompting a user to select either the <strong>id is 19876/20807/13978/49999</strong>. Then taking in user input based on up to <strong>id</strong> <strong>column</strong> and <strong>their values</strong>, and returning the respective rows within a dataframe.</p>
  <p>For example, if the user want to filter data for 19876, or anything else he must to write these id and the <strong>df2</strong> should contain data only about it.</p>
  <p><strong>Df1</strong></p>
  <pre><code>    movie_ref                              year      id
  0   Captain America: The First Avenger     1942      nan
  0   Avengers: Age of Ultron                2015      nan
  0   Avengers: Infinity War                 2017      nan
  0   Avengers: Endgame                      2018      nan
  </code></pre>
  <p><strong>Df2</strong></p>
  <pre><code>      id         movie_ref                              year
  0    19876       Captain America: The First Avenger     1942
  0    20807       Avengers: Age of Ultron                2015
  0    13978       Avengers: Infinity War                 2017
  0    49999       Avengers: Endgame                      2018
  </code></pre>
  <p>I have tried to creat something with python and pandas libraries.</p>
  <pre><code>import pandas as pd
  
  
  d = {'movie_name': ['Captain America: The First Avenger', 'Avengers: Age of Ultron', 'Avengers: Infinity War', 'Avengers: Endgame'],
   'correct_id': [ 'N/A','N/A','N/A', 'N/A'],'year':[1942,2015,2017,2018]}
  d1 = {'movie_ref': ['Captain America: The First Avenger','Avengers: Age of Ultron', 'Avengers: Infinity War', 'Avengers: Endgame'], 
  'id': ['19876', '20807','13978','49999'],'year':[1942,2015,2017,2018]}
  
  df1 = pd.DataFrame(data=d)
  df2 = pd.DataFrame(data=d1)
  print(df1)
  print(df2)
  
  filter_data = int(input('select movie writing the id: '))
  
  filtered=(df2.loc[df2['id'] == filter_data])
  print(filtered)
      
  </code></pre>
  <p>I got as <strong>an output:</strong></p>
  <pre><code>select movie writing the id: 49999
  Empty DataFrame
  Columns: [movie_ref, id, year]
  Index: []
  </code></pre>
  <p><strong>expected output</strong>:</p>
  <pre><code>     movie_ref          id     year
  0     Avengers: Endgame  49999  2018
  </code></pre>
  <p>Then i want to take the id 49999 and replace the nan in the Df1
  <strong>Final output:</strong></p>
  <pre><code>  movie_ref                              year        id
  0   Captain America: The First Avenger     1942      nan
  0   Avengers: Age of Ultron                2015      nan
  0   Avengers: Infinity War                 2017      nan
  0   Avengers: Endgame                      2018      49999
  
   
  </code></pre>