Write python code that analyzes a CSV file, determines what type of EDA (exploratory data analysis) to perform on it, and then creates a powerpoint presentation with key findings and charts included.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Sure! Here's an example of Python code that analyzes a CSV file, determines what type of EDA to perform on it, and creates a Powerpoint presentation with key findings and charts included:
python
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from powerpoint import Presentation
# Open the CSV file
df = pd.read_csv('data.csv')
# Check if the data is numeric
if not df.dtypes.all(np.number):
raise ValueError('All values in the CSV file must be numeric.')
# Perform EDA on the data
eda = df.describe()
# Create a Powerpoint presentation with the EDA results
presentation = Presentation()
# Add a title page
presentation.add_slide('Title', 'My Powerpoint Presentation')
# Add a header row
header = ['Variable', 'Min', 'Median', 'Max','mean', 'variance']
presentation.add_slide(header, 'Introduction')
# Add a subheader row
subheader = ['Description', 'N', 'Min', 'Median', 'Max','mean', 'variance']
presentation.add_slide(subheader, 'Summary')
# Add a body row for each EDA result
for i, v in eda.iterrows():
title = v['Description']
subtitle = f'{i+1}: {v['mean']:.2f} {v['variance']:.2f}'
body = f'''
{title}:
{subtitle}
'''
presentation.add_slide(body, i)
# Save the presentation as a Powerpoint file
with open('my-eda.ppt', 'wb') as f:
presentation.save(f)
In this example, the read_csv function is used to open the CSV file, and the describe function is used to determine the data type of each column. If the data is not numeric, an error is raised and the EDA cannot be performed.
The eda object is then used to perform the EDA on the data, which provides a summary of the distribution of each variable. A header row is added to the presentation with