[genropy] Pandas

  • From: Luigi Renna <luigi@xxxxxxxxxxxxx>
  • To: genropy <genropy@xxxxxxxxxxxxx>
  • Date: Tue, 7 Aug 2018 16:45:41 +0200

Io lo ho utlizzato in questo modo per delle tabelle pivot:

dati =tbl_presenza.query(columns="$nominativo, $matricola, $giorno, $totmin, $causale",
where="""$anagrafica_id IN :pkdip AND
$mese=:pkmese AND
$anno=:pkanno AND
$pres""",
order_by='$nominativo, $data_presenza',
addPkeyColumn=False,
pkdip=lista, pkmese=mese, pkanno=anno).selection().output('list')
df =pd.DataFrame.from_records(dati, columns=['Nominativo', 'Matricola', 'Giorno', 'TotMin', 'Causale'])
df =pd.pivot_table(df, index=["Nominativo", "Matricola"], columns=['Causale'], values=['TotMin'],
fill_value=0, aggfunc=[np.sum])

Ciao

Luigi Renna

Other related posts:

  • » [genropy] Pandas - Luigi Renna