# Exploring the Data

Let's start with the first use case, looking at Life Expectancy. We are interested in thinking about the factors that influence Life Expectancy. Looking at the columns dataset, and considering our use case, we can ask questions related to:

* **Economics**: What is the correlation between life expectancy and GDP per capita?
* **Time Series**: Does life expectancy change (increase/decrease) over time? Are the patterns consistent by region?
* **Regions**: Are there geographic / regional patterns in life expectancy?

Let's explore the first questions, and you can explore the second two questions on your own.

***

#### **Q1: Economics**

Let's create some visualizations related to Life Expectancy and GDP.

**Life expectancy and GDP**

```python
import plotly.express as px

fig = px.scatter(
    data_frame=df = px.data.gapminder(),
    x="lifeExp",
    y="gdpPercap",
    
)
fig.show()
```

Output:

<figure><img src="/files/nPO2EL2WUDqHFo0zqgiW" alt=""><figcaption></figcaption></figure>

Let's add a title and just look at `Year = 2007`.

<pre class="language-python"><code class="lang-python"><strong>import plotly.express as px
</strong>
fig = px.scatter(
    data_frame=df[df['year'] == 2007],
    x="lifeExp",
    y="gdpPercap",
    color="continent",
    title="Life Expectancy v GDP: 2007"
    
)
fig.show()
</code></pre>

Output

<figure><img src="/files/VqIyNE2suosloMJtZRHd" alt=""><figcaption></figcaption></figure>

### Time Series

There are several other options for charts looking at Life Expectancy and GDP per capita that explore how this effect changes over time.

* What about a visualization with pooled data, not just 2007? What about different colors by year?
* What about a visualization of the relationship for each continent?
* Does it look different to include a regression plot?

### Regions

* What is the correlation between life expectancy and GDP per capita?
* **Time Series**: Does life expectancy change (increase/decrease) over time? Are the patterns consistent by region?
* **Regions**: Are there geographic / regional correlations?


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://larhues-personal-organization.gitbook.io/intro-to-data-visualization/exercises-and-examples/the-gapminder-dataset/exploring-the-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
