xxxxxxxxxx
# import pandas as pd
import pandas as pd
# list of strings
lst = ['Geeks', 'For', 'Geeks', 'is',
'portal', 'for', 'Geeks']
# Calling DataFrame constructor on list
df = pd.DataFrame(lst)
df
xxxxxxxxxx
# import pandas as pd
import pandas as pd
# list of strings
lst = ['fav', 'tutor', 'coding', 'skills']
# Calling DataFrame constructor on list
df = pd.DataFrame(lst)
print(df)
xxxxxxxxxx
# Way 1
df.values.tolist()
# Way 2
[list(row) for row in df.iterrows()]
# Way 3
rows = []
with open('dataset.csv') as file :
rows.append(file.readline())
xxxxxxxxxx
import pandas as pd
df = pd.concat(list_of_dataframes)
# easy way
xxxxxxxxxx
import pandas as pd
# Assuming the dataframe is named 'df'
# Convert the entire dataframe to a list
df_list = df.values.tolist()
# Convert specific columns of the dataframe to a list
selected_columns = ['column1', 'column2'] # Replace with the actual column names
selected_columns_list = df[selected_columns].values.tolist()