> For the complete documentation index, see [llms.txt](https://ai-javaher.gitbook.io/pythonclass/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ai-javaher.gitbook.io/pythonclass/python-workshops/pandas-2.md).

# pandas 2

### Table of Contents:

In the Pandas part 2, we have covered the following topics:

1. **Insert Column:**

The `insert` function in Pandas allows for the insertion of new columns at specified positions within a DataFrame, offering flexibility in organizing and structuring data. This functionality is crucial for scenarios where precise column placement is required, such as when adding calculated or derived columns into existing datasets.

2. **at And iat in DataFrame:**

The `insert` function in Pandas allows for the insertion of new columns at specified positions within a DataFrame, offering flexibility in organizing and structuring data. This functionality is crucial for scenarios where precise column placement is required, such as when adding calculated or derived columns into existing datasets.

<figure><img src="https://2998778153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHvRLCXcxmjwW0q4dXdh5%2Fuploads%2FWauUi1mrIiIIj1eJA2hF%2Fimg7.jpeg?alt=media&amp;token=49d38f96-6340-4775-bc90-b481ee1b7214" alt="" width="563"><figcaption><p>Assigning values to the DataFrmae cells</p></figcaption></figure>

3. **Loops in DataFrame:**

Loops in DataFrames, such as using `iterrows` and `itertuples`, provide a way to iterate through rows of a DataFrame for various operations like data manipulation, transformation, or analysis. While convenient for smaller datasets, they can be inefficient and lead to performance issues when dealing with large datasets due to their inherently slower execution speed.

<figure><img src="https://2998778153-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHvRLCXcxmjwW0q4dXdh5%2Fuploads%2FANgJQ11KrgxYkr4Qe5ac%2Fimg9.jpeg?alt=media&amp;token=0732ff80-23bb-4ea4-a648-46c941a9cddb" alt="" width="563"><figcaption><p>Using Loops in Pandas</p></figcaption></figure>

4. **Isna, Isnin, Dropna, and Fillna:**

NaN (Not a Number) values in DataFrames represent missing or undefined data points, which can lead to erroneous analysis or computation results if not handled properly. Identifying and handling NaN values is essential to ensure data integrity and accuracy in tasks such as statistical analysis, machine learning, or visualization. Techniques like filling NaN values with appropriate data or detecting and removing them can help mitigate potential issues and ensure robust data analysis workflows.

5. **Concat in Dataframe:**

In Pandas, `concat` function concatenates DataFrames along rows, allowing the addition of rows or columns to an existing DataFrame. In older Python versions, `append` was commonly used to add rows, but it's now considered deprecated in favor of `concat`, offering similar functionality with better performance and memory efficiency.

{% embed url="<https://www.youtube.com/watch?v=jpgTlHkF9nI>" %}
Pandas Session2
{% endembed %}

### Pandas 2 Documents 📚 <a href="#numpy-2-document" id="numpy-2-document"></a>

{% file src="/files/bXraYh421FEIMkpAC7ap" %}

{% file src="/files/YemMNdmQ3f7Wmz8BYrkB" %}
