Question #121   Submitted by Answiki on 10/24/2021 at 07:22:33 AM UTC

In Pandas / Python, how to create a dataframe and populate it with given values?

Answer   Submitted by Answiki on 10/24/2021 at 07:21:08 AM UTC

The easiest way to create a Python/Pandas dataframe with given values is to create the dataframe from a list:

import pandas as pd
data = [[0, 1], [2, 3], [4, 5]] 
df = pd.DataFrame(data, columns = ['Col 1', 'Col 2']) 

The previous code creates the following dataframe:

	Col 1	Col 2
0	0		1
1	2		3
2	4		5


10 events in history
Question by Answiki 10/24/2021 at 07:22:52 AM
In Pandas / Python, how to create a dataframe and fill it with given values?
Question by Answiki 10/24/2021 at 07:22:33 AM
In Pandas / Python, how to create a dataframe and populate it with given values?
Question by Answiki 10/24/2021 at 07:22:20 AM
In Pandas / Python, how to create a dataframe and populate it with values?
Question by Answiki 10/24/2021 at 07:22:12 AM
In Pandas / Python, how to create a dataframe and fill it with values?
Answer by Answiki on 10/24/2021 at 07:21:08 AM

The easiest way to create a Python/Pandas dataframe with given values is to create the dataframe from a list:

import pandas as pd
data = [[0, 1], [2, 3], [4, 5]] 
df = pd.DataFrame(data, columns = ['Col 1', 'Col 2']) 

The previous code creates the following dataframe:

	Col 1	Col 2
0	0		1
1	2		3
2	4		5


Question by Answiki 10/24/2021 at 07:20:35 AM
In Pandas / Python, how to create and initialise a new dataframe with specified values?
Question by Answiki 10/24/2021 at 07:20:26 AM
In Pandas / Python, how to create and initialise a new dataframe with given values?
Question by Answiki 10/24/2021 at 07:20:07 AM
In Pandas / Python, how to create new dataframe with given values?
Answer by Answiki on 08/27/2020 at 01:17:38 PM

The easiest way to create a Python/Pandas dataframe with provided values is to create the dataframe from a list:

import pandas as pd
data = [[0, 1], [2, 3], [4, 5]] 
df = pd.DataFrame(data, columns = ['Col 1', 'Col 2']) 

The previous code creates the following dataframe:

	Col 1	Col 2
0	0		1
1	2		3
2	4		5


Question by Answiki 08/27/2020 at 01:13:50 PM
In Python, how to create new dataframe with given values?
# ID Query URL Count

Icons proudly provided by Friconix.