2025-04-24
Scripts: generally look good, time until Tuesday to react to feedback (make sure to submit!)
Today: finish homework 11 (functions)
Next week: submit the screencast (Thursday)
For each of the Things you defined, write out at least three paragraphs:
Make sure to:
most general form of structured data
in R:
in python, lists are base objects, dictionaries include names, come together as Series
:
access by index or by name
$name
[1] "value"
$name
[1] "value"
[1] "value"
[1] "value"
in python: access by index (list), access by name (dictionary), either (series)
JSON is list data format: each record is a set of key-value pairs, a value can consist of another list.
{ 'id': 71418862, 'organization_id': 'NE159', 'url': 'https://...',
'type': 'Dog', 'species': 'Dog', 'breeds': {'primary': 'Black Labrador Retriever', 'mixed': False, 'unknown': False}, 'colors': {'primary': 'Black'}, 'age': 'Baby', 'gender': 'Male', 'size': 'Medium', 'coat': 'Short', 'attributes': {'spayed_neutered': True, 'house_trained': True, 'special_needs': False, 'shots_current': True}, 'environment': {'children': True, 'dogs': True, 'cats': True}, 'tags': ['Couch potato', 'Curious', 'Affectionate', 'Friendly', 'Brave', 'Loyal', 'Gentle', 'Playful', 'Smart', 'Athletic', 'Funny', 'Independent', 'Loves Kisses', 'Protective', 'Dignified', 'Quiet'], 'name': 'Jalepeno', 'description': 'Jalepeno is all boy and ready to play and learn everything that you want to teach him. He is amazing...', 'photos': [{'small': 'https://...', 'medium': 'https://...', 'large': 'https://...', 'full': 'https://...'}], 'primary_photo_cropped': {'small': 'https://...', 'medium': 'https://...', 'large': 'https://...', 'full': 'https://...'}, 'videos': [], 'status': 'adoptable', 'status_changed_at': '2024-04-22T04:53:28+0000', 'published_at': '2024-04-22T04:53:27+0000', 'distance': 38.6862, 'contact': {'email': 'maws_paws@yahoo.com', 'phone': '(402) 806-1441', 'address': {'city': 'Beatrice', 'state': 'NE', 'postcode': '68310', 'country': 'US'}}, '_links': {'self': {'href': '/v2/animals/71418862'}, 'type': {'href': '/v2/types/dog'}, 'organization': {'href': '/v2/organizations/ne159'}}}
in R from purrr
package:
list_transpose
list_rbind
in python:
read_json # make sure to set typ to 'series'
json_normalize # flattens a list to a data frame