title: How do I get all the unique values from a dataframe attached to the column/s they belong to?
body: <p>I work for a mental health organization and I'm trying to pull unique session data from our database. The problem is as follows. Sometimes when new information is added like, for example, an additional signature, there's an entirely new line of duplicate information added with the same information except for that one new value. I need all unique information tied to a session (session_id). This is what it would look like as an example:</p>
  <pre><code>import pandas as pd
  
  df = pd.DataFrame({'session_id': [1, 1, 2, 3],
                       'signature': ['Bob', 'John', 'Bob', 'Bob'],
                       'patient_id': [1234, 1234, 1234, 1234],
                       'patient_name': ['Frank', 'Frank', 'Frank', 'Frank']})
  df (example created for Jupyter Notebook)
  </code></pre>
  <p>This is what I want to create for every session:</p>
  <pre><code>final_df = pd.DataFrame({'session_id': [1],
                         'signature': ['Bob'],
                         'signature_2':  ['John'],
                         'patient_id': [1234],
                         'patient_name': ['Frank']})
  final_df
  </code></pre>
  <p>I want this output regardless of where the new unique value is. So if there was an additional patient involved in the session, a new column called patient_name_2 would be generated for the new dataframe. Any help would be much appreciated.</p>
  <p>Alternatively, if this could be done from the DataBase level with some form of GROUP BY in MS SQL, let me know.</p>