I want to convert a table, represented as a list of lists, into a Pandas DataFrame
. As an extremely simplified example:
a = [[\'a\', \'1.2\', \'
When I've only needed to specify specific columns, and I want to be explicit, I've used (per DOCS LOCATION):
dataframe = dataframe.astype({'col_name_1':'int','col_name_2':'float64', etc. ...})
So, using the original question, but providing column names to it ...
a = [['a', '1.2', '4.2'], ['b', '70', '0.03'], ['x', '5', '0']]
df = pd.DataFrame(a, columns=['col_name_1', 'col_name_2', 'col_name_3'])
df = df.astype({'col_name_2':'float64', 'col_name_3':'float64'})