@@ -4,7 +4,8 @@ description: "Learn how to work with views in PandasAI"
44---
55
66<Note title = " Beta Notice" >
7- PandasAI 3.0 is currently in beta. This documentation reflects the latest features and functionality, which may evolve before the final release.
7+ PandasAI 3.0 is currently in beta. This documentation reflects the latest
8+ features and functionality, which may evolve before the final release.
89</Note >
910
1011## What are views?
@@ -68,21 +69,21 @@ view_relations = [
6869# Select relevant columns for the sales analytics view
6970view_columns = [
7071 # Order details
71- " orders.id" ,
72- " orders.order_date" ,
73- " orders.total_amount" ,
74- " orders.status" ,
75-
72+ { " name " : " orders.id" , " type " : " integer " } ,
73+ { " name " : " orders.order_date" , " type " : " date " } ,
74+ { " name " : " orders.total_amount" , " type " : " float " } ,
75+ { " name " : " orders.status" , " type " : " string " } ,
76+
7677 # Product information
77- " products.name" ,
78- " products.category" ,
79- " products.unit_price" ,
80- " products.stock_level" ,
81-
78+ { " name " : " products.name" , " type " : " string " } ,
79+ { " name " : " products.category" , " type " : " string " } ,
80+ { " name " : " products.unit_price" , " type " : " float " } ,
81+ { " name " : " products.stock_level" , " type " : " integer " } ,
82+
8283 # Customer information
83- " customers.segment" ,
84- " customers.country" ,
85- " customers.join_date"
84+ { " name " : " customers.segment" , " type " : " string " } ,
85+ { " name " : " customers.country" , " type " : " string " } ,
86+ { " name " : " customers.join_date" , " type " : " date " },
8687]
8788
8889# Create a comprehensive sales analytics view
@@ -125,16 +126,19 @@ relations:
125126#### Constraints
126127
1271281. **Mutual Exclusivity**:
129+
128130 - A schema cannot define both ` table` and `view` simultaneously.
129131 - If `view` is `true`, then the schema represents a view.
130132
1311332. **Column Format** :
134+
132135 - For views :
133136 - All columns must follow the format `[table].[column]`.
134137 - ` from` and `to` fields in `relations` must follow the `[table].[column]` format.
135138 - Example : ` loans.payment_amount` , `heart.condition`.
136139
1371403. **Relationships for Views** :
141+
138142 - Each table referenced in `columns` must have at least one relationship defined in `relations`.
139143 - Relationships must specify `from` and `to` attributes in the `[table].[column]` format.
140144 - Relations define how different tables in your view are connected.
0 commit comments