> For the complete documentation index, see [llms.txt](https://igb.mit.edu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://igb.mit.edu/mini-courses/python/data-processing-with-python/pandas/inspecting-dataframes.md).

# Inspecting DataFrames

Pandas provides some simple methods to look at your dataframes:&#x20;

* `[your_dataframe_name].head(5)` will provide the first 5 rows
* `[your_dataframe_name].tail(10)` will provide the last 10 rows
* `[your_dataframe_name].describe()` is a quick way to get summary statistics on a per-column basis

You can find more useful pandas functions \[[here](https://pandas.pydata.org/pandas-docs/stable/reference/frame.html)]

```
ms.head() #this will give the first 5 rows by default. You can add any number in the () to get that number of rows
```

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

```
ms.tail(10) #and the last 10 rows
```

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

```
ms.describe() #this is a quick way to get summary statistics on a per-column basis
```

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

```
#What do you notice about the number of columns returned by describe vs that in the entire dataframe...
ms.shape
```

(216, 183)

```
ms.columns
```

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

```
missing = []
des_cols = ms.describe().columns
for col in ms.columns:
    if col in des_cols:
        print('found: '+ col)
    else:
        missing.append(col)
```

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

```
missing
```

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

```
pd.set_option('display.max_rows', 50) #This will set the number of rows you can "see" in the jupyter notebook when you inspect a dataframe
pd.set_option('display.max_columns', 200) #This will set the number of columns you can "see" in the jupyter notebook when you inspect a dataframe
```

```
ms.describe() #notice the difference in the number of columns you can see
```

<figure><img src="/files/6IoGonqA4kP3sg39iBn6" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://igb.mit.edu/mini-courses/python/data-processing-with-python/pandas/inspecting-dataframes.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
