In Pandas / Python, how to create and initialise a new dataframe with given values?
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
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
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
| # | ID | Query | URL | Count |
|---|---|---|---|---|
| 0 | 12322 | en | https://en.ans.wiki/117/in-pandas-slash-python-how-to-create-and-initialise-a-new-dataframe-with-given-values | 6 |