Inside of a Django view:

    my_names = ['Date','Open','High','Low','Close','Volume','B0','B1','B2','B3','B4','B5','B6','B7']
    request.session['df'] = pd.read_csv( request.FILES.get('data'), names=my_names ).to_json()
    if request.session.test_cookie_worked():
        print('Test cookie worked! Deleting... ')
        request.session.delete_test_cookie()
    else:
        request.session.set_test_cookie()
        print('set test cookie')

Problem description

If I comment out the line "request.session['df'] = pd.read_csv( request.FILES.get('data'), names=my_names ).to_json()", then the first page load will print "set test cookie" on the first page load. On the second page load, the link 'Test cookie worked! Deleting..." will appear.

When I run the code as-is, the Terminal prints set test cookie on every single page load.

GitHub won't let me upload the csv file even though it's zipped. Let me know how I can send that to you.

Expected Output

The terminal output should alternate between 'set test cookie' and 'Test cookie worked!' on every page load.

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.5.2.final.0 python-bits: 64 OS: Linux OS-release: 4.4.0-51-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 pandas: 0.19.1 nose: None pip: 9.0.1 setuptools: 20.7.0 Cython: None numpy: 1.11.2 scipy: None statsmodels: None xarray: None IPython: None sphinx: None patsy: None dateutil: 2.6.0 pytz: 2016.7 blosc: None bottleneck: None tables: None numexpr: None matplotlib: 1.5.3 openpyxl: None xlrd: None xlwt: None xlsxwriter: 0.7.3 lxml: None bs4: 4.4.1 html5lib: 0.999 httplib2: 0.9.1 apiclient: None sqlalchemy: None pymysql: None psycopg2: None jinja2: 2.8 boto: None pandas_datareader: None None

Comment From: jreback

this is not a reproducible example; its also not clear what this has to do with pandas itself. more likely how you are using the results.

Comment From: jreback

you are likely to get more of a response on Stack Overflow; you need to post a complete self-reproducible example.