convert table into dataframe from column value in python

To convert a table into a dataframe from column values in Python, you can use the Pandas library. Here is a sample code that demonstrates how to do it:

main.py
import pandas as pd

# Define table data
table = {
    'Column1': [1, 2, 3],
    'Column2': ['A', 'B', 'C'],
    'Column3': [4.5, 6.7, 8.0]
}

# Convert table to dataframe
df = pd.DataFrame(table)

# Print dataframe
print(df)
226 chars
15 lines

In this code, we define the table data as a dictionary where each key represents a column name and each value represents a list of values for that column. We then use the pd.DataFrame() function to convert the table into a dataframe. Finally, we print the resulting dataframe using the print() function.

gistlibby LogSnag