Ho un elenco di dataframe Pandas che vorrei combinare in un dataframe Pandas. Sto usando Python 2.7.10 e Pandas 0.16.2
Ho creato l'elenco dei dataframe da:
import pandas as pd
dfs = []
sqlall = "select * from mytable"
for chunk in pd.read_sql_query(sqlall , cnxn, chunksize=10000):
dfs.append(chunk)
Ciò restituisce un elenco di dataframe
type(dfs[0])
Out[6]: pandas.core.frame.DataFrame
type(dfs)
Out[7]: list
len(dfs)
Out[8]: 408
Ecco alcuni dati di esempio
# sample dataframes
d1 = pd.DataFrame({'one' : [1., 2., 3., 4.], 'two' : [4., 3., 2., 1.]})
d2 = pd.DataFrame({'one' : [5., 6., 7., 8.], 'two' : [9., 10., 11., 12.]})
d3 = pd.DataFrame({'one' : [15., 16., 17., 18.], 'two' : [19., 10., 11., 12.]})
# list of dataframes
mydfs = [d1, d2, d3]
Vorrei unire d1, d2e d3in un unico panda dataframe. In alternativa, un metodo per leggere una tabella di grandi dimensioni direttamente in un dataframe quando si utilizza l' chunksizeopzione sarebbe molto utile.