Question #143
In Python, how to create new dataframe with given values?
Merged questions
Answer
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
2 events in history
Answer by Alphonsio 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 Alphonsio 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.