# Pandas

```python
import pandas as pd

fullCorpus = pd.DataFrame({
  'label': labelList,
  'body_list': textList
})

fullCorpus.head() #print first 5 rows
```

## Access

```python
df['date'] #just date column 
df[df['date'] > '2017-03-20'] # just date columns that meet criteria
```

### Filter

```python
df = df.drop(['high','low','close','volume'], axis=1) #get rid of columns
```

### Indexing

Use `X.iloc[0]` instead of `X[0]`

## Read in seperated data

```python
fullCorpus = pd.read_csv("file.tsv", sep="\t", header=None)
# header default assumes first row is the column names
fullsCorpus.columns = ['label', 'body_text'] # add columns
```

## Create New Column

`pdData['clean_text'] = data['body_text'].apply(lambda x: remove_punct(x))`


---

# 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://openai.gitbook.io/code-cheatsheets/all/python/packages/pandas.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.
