In this post, you will learn about **how to create a Pandas dataframe** with some **sample data.** The following represent two different techniques using which one can create the Pandas Dataframe:

- Create Dataframe without using Numpy Array
- Create Dataframe using Numpy Array

## Create Dataframe without using Numpy Array

Here is the python code for creating a Pandas dataframe without using Numpy array:

```
import pandas as pd
#
# Create dataframe
#
df = pd.DataFrame([['Ajitesh', 84, 183, 'no'],
['Shailesh', 79, 186, 'yes'],
['Seema', 67, 158, 'yes'],
['Nidhi', 52, 155, 'no']])
#
# Assign column names
#
df.columns = ['name', 'weight', 'height', 'smoke_or_not']
#
# Print dataframe
#
df
```

## Create Dataframe using Numpy Array

Here is the code for creating a dataframe using Numpy array. Note the usage of **np.array **used for creating an instance of **Numpy Ndarray**.

```
import numpy as np
#
# Create dataframe
#
df = pd.DataFrame(np.array([['Ajitesh', 84, 183, 'no'],
['Shailesh', 79, 186, 'yes'],
['Seema', 67, 158, 'no'],
['Nidhi', 52, 155, 'no']]))
#
# Assign column names
#
df.columns = ['name', 'weight', 'height', 'smoke_or_not']
#
# Print dataframe
#
df
```

The following will be printed:

- First Principles Understanding based on Physics - April 13, 2021
- Precision & Recall Explained using Covid-19 Example - April 11, 2021
- Moving Average Method for Time-series forecasting - April 4, 2021

## Leave a Reply