Мне кажется, нужно DataFrameGroupBy.agg
со словарем столбцов со списками функций, get MultiIndex
, поэтому необходимо сгладить map
и последние rename
столбцы:
d = {'BeginDate':['first','last', 'size'],
'start_price':['first','last'],
'agr_signal':'first'}
df = df.groupby('agr_group').agg(d)
df.columns = df.columns.map('_'.join)
d = {'BeginDate_first':'BeginDate1',
'BeginDate_last':'EndDate1',
'BeginDate_size':'Consecutive1',
'start_price_first':'start_price1',
'start_price_last':'end_price1',
'agr_signal_first':'agr_signal1'}
df = df.reset_index().rename(columns=d)
print (df)
agr_group BeginDate1 EndDate1 Consecutive1 start_price1 end_price1 \
0 1.0 2018-03-22 2018-04-07 3 0.000997 0.000795
1 2.0 2018-04-09 2018-04-09 1 0.000713 0.000713
2 3.0 2018-04-12 2018-04-12 1 0.000876 0.000876
3 4.0 2018-04-21 2018-04-21 1 0.004250 0.004250
agr_signal1
0 -1
1 0
2 1
3 -1
Вы должны использовать appBar: AppBar(...
внутри своей эшафот. Поэтому MaterialApp-> Scaffold -> (AppBar и listview).
Пример кода:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("This is the title"),
),
body: ListView(
children: <Widget>[
Text("This is text 1"),
Text("This is text 2"),
Text("This is text 3"),
Text("This is text 4"),
Text("This is text 5"),
Text("This is text 6"),
Text("This is text 7"),
Text("This is text 8"),
Text("This is text 9"),
Text("This is text 10"),
Text("This is text 11"),
Text("This is text 12"),
Text("This is text 13"),
Text("This is text 14"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
Text("This is text 15"),
],
),
),
);
}
}