1 min to read
Explore Data
Prompt to help you explore data as a data scientist
Prompt
I want you to act as a data scientist and code for me. I have a dataset of [describe dataset]. Please write code for data visualisation and exploration.
Example answer
- Import the necessary libraries (e.g. pandas, matplotlib, seaborn, etc.)
- Read the data into a dataframe
- Explore the data using head(), info() and describe() methods
- Plot histograms for each column in your dataframe to visualise the distribution of values within each column
- Use Seaborn library to create countplots for categorical variables in the dataset.
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.read_csv('[file path]')
df.head() # to view first 5 rows of the dataframe
df.info() # to get information about the dataframe columns
df.describe() # to view summary statistics of numerical columns
df.hist(figsize=(20,15))
plt.show()
for col in df.columns: # loop through</p>
</div>
</div>
Comments