title: How to store the value of each element of pandas data frame in redis
body: <p>I am writing a program that will read a data frame from csv file, then calculate the hash values for one of the attributes(columns) and store it as a new attribute at the data frame.  All of that is working fine.  However, what I want is to store the hash attribute as my key and the original attribute as its value in redis.  And I would like to do that to for each element in the specified columns in the data frame.  For example:</p>
  
  <p>This is my original data frame :</p>
  
  <pre><code>  customer     value
       a           1
       b           2
       c           3
  </code></pre>
  
  <p>Then I want to calculate the hash for the value attribute:</p>
  
  <pre><code>  customer     value      hash
       a           1        23344
       b           2        34567 
       c           3        78987
  </code></pre>
  
  <p>Finally I want to store the hash attribute as my key in Redis and value as my value, so for example if I ask to get</p>
  
  <pre><code> r.get(23344) 
  </code></pre>
  
  <p>the expected answer will be:
            '1'</p>
  
  <p>or :</p>
  
  <pre><code>&gt; r.get('78987')
  &gt; '3'
  </code></pre>
  
  <p>Below is my python code, I reached to the part of r.set, my problem is that it is saving the whole attribute under the attribute name, so I am not able to query for a single element.</p>
  
  <pre><code>import hashlib
  import pandas as pd
  import numpy as np
  import redis
  
  r = redis.Redis(host='localhost', port=6379, db=0)
  df= pd.read_csv ('file.csv') 
  df['hash']=df['value'].apply(hash) 
  
  r.set(df['hash'],df['value'])
  </code></pre>
  
  <p>I apologize for the long explanation and I hope to get some hints as I am new to work with pandas and redis</p>