File tree Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -1469,8 +1469,8 @@ of the nasa_data object. But you can reproduce this using the DEMO_KEY key -->
1469
1469
import requests
1470
1470
1471
1471
nasa_data_single = requests.get(
1472
- " https://api.nasa.gov/planetary/apod?api_key=YOUR_API_KEY&date=2023-07-13"
1473
- ).json()
1472
+ " https://api.nasa.gov/planetary/apod?api_key=YOUR_API_KEY&date=2023-07-13"
1473
+ ).json()
1474
1474
nasa_data_single
1475
1475
```
1476
1476
@@ -1492,8 +1492,8 @@ and there will be 74 items total, one for each day between the start and end dat
1492
1492
1493
1493
``` python
1494
1494
nasa_data = requests.get(
1495
- " https://api.nasa.gov/planetary/apod?api_key=YOUR_API_KEY&start_date=2023-05-01&end_date=2023-07-13"
1496
- ).json()
1495
+ " https://api.nasa.gov/planetary/apod?api_key=YOUR_API_KEY&start_date=2023-05-01&end_date=2023-07-13"
1496
+ ).json()
1497
1497
len (nasa_data)
1498
1498
```
1499
1499
@@ -1513,17 +1513,17 @@ readers who would like to parse JSON data into a `pandas` data frame in their ow
1513
1513
1514
1514
``` {code-cell} ipython3
1515
1515
data_dict = {
1516
- "date":[],
1517
- "title": [],
1518
- "copyright" : [],
1519
- "url": []
1516
+ "date":[],
1517
+ "title": [],
1518
+ "copyright" : [],
1519
+ "url": []
1520
1520
}
1521
1521
1522
1522
for item in nasa_data:
1523
- if "copyright" not in item:
1524
- item["copyright"] = None
1525
- for entry in ["url", "title", "date", "copyright"]:
1526
- data_dict[entry].append(item[entry])
1523
+ if "copyright" not in item:
1524
+ item["copyright"] = None
1525
+ for entry in ["url", "title", "date", "copyright"]:
1526
+ data_dict[entry].append(item[entry])
1527
1527
1528
1528
nasa_df = pd.DataFrame(data_dict)
1529
1529
nasa_df
You can’t perform that action at this time.
0 commit comments