I found a quick and easy solution to what I wanted using json_normalize()
included in pandas 1.01
.
from urllib2 import Request, urlopen import json import pandas as pd path1 = '42.974049,-81.205203|42.974298,-81.195755' request=Request('http://maps.googleapis.com/maps/api/elevation/json?locations='+path1+'&sensor=false') response = urlopen(request) elevations = response.read() data = json.loads(elevations) df = pd.json_normalize(data['results'])
This gives a nice flattened dataframe with the json data that I got from the Google Maps API.
Related Posts:
- pandas read_json: “If using all scalar values, you must pass an index”
- Type error: cannot convert the series to
- Loading a file with more than one line of JSON into Pandas
- ValueError: Expected object or value when reading json as pandas dataframe
- Renaming column names in Pandas
- Delete a column from a Pandas DataFrame
- Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
- Writing a pandas DataFrame to CSV file
- Adding new column to existing DataFrame in Python pandas
- Modifing data while using iterrows() does not work
- JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- Converting dictionary to JSON
- How to change the order of DataFrame columns?
- What does `ValueError: cannot reindex from a duplicate axis` mean?
- JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- ValueError: Unknown label type: ‘continuous’
- How to fix IndexError: invalid index to scalar variable
- Create a Pandas Dataframe by appending one row at a time
- json.dumps vs flask.jsonify
- How do I select rows from a DataFrame based on column values?
- How do I get the row count of a Pandas DataFrame?
- Python Pandas Counting the Occurrences of a Specific value
- Convert pandas dataframe to NumPy array
- Count unique values per groups with Pandas
- Convert pandas Series to DataFrame
- Error:cannot convert float NaN to integer in pandas
- Replacing column values in a pandas DataFrame
- TypeError: unhashable type: ‘dict’, when dict used as a key for another dict
- How do I get the row count of a Pandas DataFrame?
- Pandas “Can only compare identically-labeled DataFrame objects” error
- Pandas: ValueError: cannot convert float NaN to integer
- Get list from pandas dataframe column or row?
- ValueError: Length of values does not match length of index | Pandas DataFrame.unique()
- ‘DataFrame’ object has no attribute ‘sort’
- ‘DataFrame’ object has no attribute ‘sort’
- TypeError: cannot unpack non-iterable int objec
- Pandas DataFrame column to list
- Rename Pandas DataFrame Index
- Convert DataFrame column type from string to datetime, dd/mm/yyyy format
- How to customize a scatter matrix to see all titles?
- Get a list from Pandas DataFrame column headers
- What is dtype(‘O’), in pandas?
- Convert a python dict to a string and back
- TypeError: Object of type ‘bytes’ is not JSON serializable
- Python TypeError: cannot convert the series to
when trying to do math on dataframe - Shuffle DataFrame rows
- How to take column-slices of dataframe in pandas
- Python error load JSON code of google API
- How to overcome “datetime.datetime not JSON serializable”?
- Group by index + column in pandas
- How to iterate over columns of pandas dataframe to run regression
- Convert a Pandas DataFrame to a dictionary
- Create a Pandas Dataframe by appending one row at a time
- Modify the legend of pandas bar plot
- Displaying better error message than “No JSON object could be decoded”
- Count unique values using pandas groupby
- Ignoring NaNs with str.containsv
- Converting XML to JSON using Python?
- Count unique values per groups with Pandas [duplicate]
- Map to List error: Series object not callable
- Pandas DataFrame: replace all values in a column, based on condition
- How to convert string to datetime format in pandas python?
- No numeric types to aggregate – change in groupby() behaviour?
- Pandas – How to flatten a hierarchical index in columns
- What is the difference between json.load() and json.loads() functions
- Pandas OR statement ending in series contains
- How to convert an XML string to a dictionary?
- Solution for SpecificationError: nested renamer is not supported while agg() along with groupby()
- How to check if a column exists in Pandas
- How to get a value from a cell of a dataframe?
- Pandas split DataFrame by column value
- Groupby value counts on the dataframe pandas
- Pandas – Drop function error (label not contained in axis)
- Pandas index column title or name
- Building multi-regression model throws error: `Pandas data cast to numpy dtype of object. Check input data with np.asarray(data).`
- datetime to string with series in pandas
- import pandas_datareader gives ImportError: cannot import name ‘is_list_like’
- How to add pandas data to an existing csv file?
- Importing Pandas gives error AttributeError: module ‘pandas’ has no attribute ‘core’ in iPython Notebook
- pandas groupby sort within groups
- JSON object must be str, bytes or bytearray, not dict
- if else function in pandas dataframe
- cannot convert the series to
- Read data (.dat file) with Pandas
- TypeError: expected str, bytes or os.PathLike object, not _io.TextIOWrapper
- How to convert index of a pandas dataframe into a column
- Replacing Pandas or Numpy Nan with a None to use with MysqlDB
- pandas replace multiple values one column
- Boolean Series key will be reindexed to match DataFrame index
- Convert floats to ints in Pandas?
- pandas comparison raises TypeError: cannot compare a dtyped [float64] array with a scalar of type [bool]
- Difference between data type ‘datetime64[ns]’ and ‘
- pandas: multiple conditions while indexing data frame – unexpected behavior
- Extract first and last row of a dataframe in pandas
- Logical operators for Boolean indexing in Pandas
- TypeError: the JSON object must be str, not ‘bytes’
- How to update Pandas from Anaconda and is it possible to use eclipse with this last
- Error in Reading a csv file in pandas[CParserError: Error tokenizing data. C error: Buffer overflow caught – possible malformed input file.]
- Extracting specific selected columns to new DataFrame as a copy
- Compare two columns using pandas