Ingesting JSON data with pandas
When developing a data pipeline, you may have to work with non-tabular data and data sources, such as APIs or JSON files. In this exercise, we'll practice extracting data from a JSON file using pandas.
pandas has been imported as pd, and the JSON file you'll ingest is stored at the path "testing_scores.json".
Latihan ini adalah bagian dari kursus
ETL and ELT in Python
Petunjuk latihan
- Update the
extract()function read a JSON file into apandasDataFrame, orienting by records. - Pass the path
testing_scores.jsonto theextract()function, and store the output to a variable calledraw_testing_scores. - Print the head of the
raw_testing_scoresDataFrame.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
def extract(file_path):
# Read the JSON file into a DataFrame
return pd.____(____, orient="____")
# Call the extract function with the appropriate path, assign to raw_testing_scores
____
# Output the head of the DataFrame
print(raw_testing_scores.____())