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:

Latest posts by Ajitesh Kumar (see all)

- How to Setup / Install MLFlow & Get Started - October 20, 2020
- Python – How to Add Trend Line to Line Chart / Graph - October 20, 2020
- Top Tutorials – Neural Network Back Propagation Algorithm - October 19, 2020