
<SYSTEM_TASK:>
Given the following text problem statement, write Python code to implement the functionality described below in problem statement
<END_TASK>
<USER_TASK:>
Problem:
Reading CSV Files from Amazon S3 into Pandas Dataframes

<ASSISTANT_TASK:>
Python Code::
import pandas as pd
import boto3
from io import StringIO
# Set your AWS credentials and region
aws_access_key_id = 'access_key_id'
aws_secret_access_key = 'secret_access_key'
aws_region = 'aws_region'
# Set the S3 bucket and file path
s3_bucket = 's3_bucket_name'
s3_file_path = 'data.csv'
# Create a session with boto3
session = boto3.Session(
    aws_access_key_id=aws_access_key_id,
    aws_secret_access_key=aws_secret_access_key,
    region_name=aws_region
)
# Create an S3 client
s3 = session.client('s3')
# Read the CSV file from S3 into a pandas dataframe
s3_object = s3.get_object(Bucket=s3_bucket, Key=s3_file_path)
s3_data = s3_object['Body'].read().decode('utf-8')
df = pd.read_csv(StringIO(s3_data))
# Print the dataframe
print(df.head())

<END_TASK>
