2

I'm trying to export a pandas dataframe to JSON with no luck. I've tried:

all_data.to_json("spdata.json") and all_data.to_json()

I get the same attribute error on both: 'DataFrame' object has no attribute 'to_json'. Just to make sure something isn't wrong with the DataFrame, i tested writing it to_csv and that worked.

Is there something i'm missing in my syntax or package i need to import? I am running Python version 2.7.5 which is part of an Enthought Canopy Express package. Imports at the beginning of my code are:

from pandas import Series, DataFrame
import pandas as pd
import numpy as np
from sys import argv
from datetime import datetime, timedelta
from dateutil.parser import parse
2
  • 3
    you need at least pandas 0.12 Commented Sep 16, 2013 at 16:11
  • Rookie mistake. I installed my python environment about 3 weeks after the pandas 0.12 release so assumed i was up to date. Just updated pandas and it works fine. Thanks. Commented Sep 16, 2013 at 16:47

1 Answer 1

3

The to_json method was introduced to 0.12, so you'll need to upgrade your pandas to be able to use it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.