Usage¶
Helpers¶
You can use the dynamodb.dynamodb_helpers.get_path_to_data()
function:
- dynamodb.dynamodb_helpers.get_path_to_data()¶
Return path to data.
Raw data folder is returned by dynamodb.dynamodb_helpers.get_raw_data_path()
function:
- dynamodb.dynamodb_helpers.get_raw_data_path()¶
Return path to raw data.
You can also use the dynamodb.dynamodb_helpers.get_tidy_data_path()
function:
- dynamodb.dynamodb_helpers.get_tidy_data_path()¶
Return path to tidy data.
DynamoDB¶
To create a DynamoDB resource, use the dynamodb.dynamodb_helpers.get_dynamodb_resource
function:
- dynamodb.dynamodb_helpers.get_dynamodb_resource()¶
Creates a DynamoDB resource using the AWS session.
- Returns:
dynamo_resource: The DynamoDB resource.
To list all DynamoDB tables, use the dynamodb.dynamodb_helpers.list_dynamodb_tables
function:
- dynamodb.dynamodb_helpers.list_dynamodb_tables(dynamo_resource)¶
Lists all tables in the DynamoDB resource.
- Args:
dynamo_resource: The DynamoDB resource.
- Returns:
list: List of table names.
To get the movies table from DynamoDB, use the dynamodb.dynamodb_helpers.get_movies_table
function:
- dynamodb.dynamodb_helpers.get_movies_table(dynamo_resource)¶
Gets the movies table from DynamoDB.
- Args:
dynamo_resource: The DynamoDB resource.
- Returns:
table: The DynamoDB table resource for movies.
To get a specific movie item, use the dynamodb.dynamodb_helpers.get_movie_item
function:
- dynamodb.dynamodb_helpers.get_movie_item(table, year, title)¶
Gets a movie item from the DynamoDB table.
- Args:
table: The DynamoDB table resource. year: The year of the movie. title: The title of the movie.
- Returns:
dict: The movie item.
To query movies by year, use the dynamodb.dynamodb_helpers.query_movies_by_year
function:
- dynamodb.dynamodb_helpers.query_movies_by_year(table, year)¶
Queries movies by year from the DynamoDB table.
- Args:
table: The DynamoDB table resource. year: The year to query.
- Returns:
list: List of movies for the given year.
Data Transformation¶
To transform raw movie data into a tidy DataFrame, use the dynamodb.dynamodb_helpers.tidy_movie_data
function:
- dynamodb.dynamodb_helpers.tidy_movie_data(movies)¶
Transforms the raw movie data into a tidy DataFrame.
- Args:
movies (list): List of raw movie data.
- Returns:
DataFrame: Tidy DataFrame containing movie data.