Skip to content

Commit 7a7379f

Browse files
committed
multi-table support and demo
1 parent b7f4606 commit 7a7379f

File tree

3 files changed

+195
-34
lines changed

3 files changed

+195
-34
lines changed

py-src/data_formulator/agents/agent_data_rec.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
(4) "visualization_fields" should be no more than 3 (for x,y,legend).
5353
(5) "chart_type" must be one of "point", "bar", "line", or "boxplot"
5454
55-
2. Then, write a python function based on the inferred goal, the function input is a dataframe "df" and the output is the transformed dataframe "transformed_df". "transformed_df" should contain all "output_fields" from the refined goal.
55+
2. Then, write a python function based on the inferred goal, the function input is a dataframe "df" (or multiple dataframes based on tables presented in the [CONTEXT] section) and the output is the transformed dataframe "transformed_df". "transformed_df" should contain all "output_fields" from the refined goal.
5656
The python function must follow the template provided in [TEMPLATE], do not import any other libraries or modify function name. The function should be as simple as possible and easily readable.
5757
If there is no data transformation needed based on "output_fields", the transformation function can simply "return df".
5858
@@ -63,11 +63,15 @@
6363
import collections
6464
import numpy as np
6565
66-
def transform_data(df):
66+
def transform_data(df1, df2, ...):
6767
# complete the template here
6868
return transformed_df
6969
```
7070
71+
note:
72+
- if the user provided one table, then it should be def transform_data(df1), if the user provided multiple tables, then it should be def transform_data(df1, df2, ...) and you should consider the join between tables to derive the output.
73+
- try to use table names to refer to the input dataframes, for example, if the user provided two tables city and weather, you can use `transform_data(df_city, df_weather)` to refer to the two dataframes.
74+
7175
3. The [OUTPUT] must only contain a json object representing the refined goal and a python code block representing the transformation code, do not add any extra text explanation.
7276
'''
7377

src/views/ConceptShelf.tsx

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,37 @@ export const ConceptShelf: FC<ConceptShelfProps> = function ConceptShelf() {
182182
</Box>
183183
</Divider>
184184
</Box>
185-
{!expandedGroups.includes(groupName) && !isCustomGroup && (
185+
186+
<Box
187+
sx={{
188+
maxHeight: expandedGroups.includes(groupName) || isCustomGroup ? '1000px' : '240px',
189+
overflow: 'hidden',
190+
transition: 'max-height 0.3s ease-in-out',
191+
width: '100%'
192+
}}
193+
>
194+
{(expandedGroups.includes(groupName) || isCustomGroup ? fields : fields.slice(0, 5)).map((field) => (
195+
<ConceptCard key={`concept-card-${field.id}`} field={field} />
196+
))}
197+
{!expandedGroups.includes(groupName) && !isCustomGroup && fields.length > 5 && (
198+
<Box sx={{
199+
position: 'relative',
200+
height: '40px',
201+
'&::after': {
202+
content: '""',
203+
position: 'absolute',
204+
bottom: 0,
205+
left: 0,
206+
right: 0,
207+
height: '100%',
208+
background: 'linear-gradient(to bottom, transparent, white)'
209+
}
210+
}}>
211+
<ConceptCard field={fields[5]} />
212+
</Box>
213+
)}
214+
</Box>
215+
{!expandedGroups.includes(groupName) && !isCustomGroup && fields.length > 5 && (
186216
<Button
187217
onClick={() => updateExpandedGroup(groupName, true)}
188218
sx={{
@@ -198,23 +228,13 @@ export const ConceptShelf: FC<ConceptShelfProps> = function ConceptShelf() {
198228
}
199229
}}
200230
>
201-
{`add fields from ${groupName} for tables joins`}
231+
{`... show all ${fields.length} ${groupName} fields ▾`}
202232
</Button>
203233
)}
204-
<Box
205-
sx={{
206-
maxHeight: expandedGroups.includes(groupName) || isCustomGroup ? '1000px' : '0px',
207-
overflow: 'hidden',
208-
transition: 'max-height 0.3s ease-in-out'
209-
}}
210-
>
211-
{fields.map((field) => (
212-
<ConceptCard key={`concept-card-${field.id}`} field={field} />
213-
))}
214-
</Box>
215234
</>
216235
)
217236
})}
237+
<Divider orientation="horizontal" textAlign="left" sx={{mt: 1}}></Divider>
218238
</Box>
219239
</Box>
220240
</Box>

0 commit comments

Comments
 (0)