Storing pandas dataframe in a local machine
<p>I have a pandas dataframe in the following format:</p>

<pre><code>  File         Hour

  test1          0
  test2          1
  test1          1
</code></pre>

<p>I am trying to convert it to json and then store it in a local file location using the below command:</p>

<pre><code>df1.to_json("\home\user1\Desktop\jsonfiles\df1.json")
</code></pre>

<p>But the file does not get saved in the above location. Not sure where I am going wrong. Any help would be appreciated.</p>

<p>You can try to find your CSV file (if it was successfully written to disk, otherwise please post a full error stack) this way:</p>

<pre><code>In [40]: fn = '/home/user1/Desktop/jsonfiles/df1.json'

In [41]: df.to_json(fn)

In [42]: f = open(fn)

In [43]: import os

In [44]: print(os.path.abspath(f.name))
C:\temp\aa.csv
</code></pre>

python pandas dataframe