Skip to content
This repository was archived by the owner on Nov 14, 2025. It is now read-only.

Commit 943fd63

Browse files
committed
Updated Readme
1 parent 8874486 commit 943fd63

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,14 @@ For convenience we retrieve it as a pandas dataframe.
151151
df = client.temporal.get(e, ctx=PARKING_CONTEXT, as_dataframe=True)
152152
```
153153

154-
Let's display the last rows.
154+
Let's display the three last rows.
155155

156156
```python
157-
df.tail()
157+
df.tail(3)
158158
```
159159

160160
| | OffStreetParking | observed | availableSpotNumber |
161161
|---:|:-------------------|:--------------------------|----------------------:|
162-
| 8 | Downtown1 | 2022-10-25 16:00:00+00:00 | 41 |
163-
| 9 | Downtown1 | 2022-10-25 17:00:00+00:00 | 31 |
164162
| 10 | Downtown1 | 2022-10-25 18:00:00+00:00 | 21 |
165163
| 11 | Downtown1 | 2022-10-25 19:00:00+00:00 | 11 |
166164
| 12 | Downtown1 | 2022-10-25 20:00:00+00:00 | 1 |
@@ -181,16 +179,16 @@ For the moment just see how it is occupied.
181179
```python
182180
n_total = parking["totalSpotNumber"].value
183181
n_occupied = parking["occupiedSpotNumber"].value
184-
n_free= parking["availableSpotNumber"].value
182+
n_avail= parking["availableSpotNumber"].value
185183
print(n_total, n_occupied, n_avail)
186184
```
187185

188-
This parking has 414 parking slots. 282 are occupied. 132 are free.<br>
186+
This parking has 414 parking slots. 282 are occupied. 132 are available.<br>
189187
In order to complete our parking system we would like to add 414 spots to our datamodel.<br>
190188
Let's create a reference parking spot to be used as a template.
191189

192190
```python
193-
spot = Spot("ParkingSpot", "OffStreetParking:porto-ParkingLot-23889:000")
191+
spot = Entity("ParkingSpot", "OffStreetParking:porto-ParkingLot-23889:000")
194192
spot.prop("status", "free")
195193
spot.rel("refParkingSite", parking)
196194
```
@@ -206,7 +204,9 @@ for i, spot in enumerate(spots):
206204
spot["status"].value = "occupied"
207205
```
208206

209-
We now establish the relationship between the parking and its spots by adding a new attribute to the parking.
207+
We now establish the relationship between the parking and its spots by adding a new attribute to the parking.<br>
208+
Having a mutual relationship is not necessarily needed. It depends on how we want to navigate in our datamodel. <br>
209+
Let's do it for the sake of example.
210210

211211
```python
212212
from ngsildclient import MultAttrValue
@@ -218,10 +218,10 @@ parking.rel("refParkingSpot", mrel)
218218
```
219219

220220
To sum up we have obtained 415 entities : 1 parking and 414 spots.<br>
221-
Make a single array of these parts and save it into a file.
221+
Make a single list of these parts and save it into a file.
222222

223223
```python
224-
datamodel = sum([[parking], spots], []) # flatten arrays
224+
datamodel = sum(([parking], spots), []) # flatten lists
225225
Entity.save_batch(datamodel, "parking_system.jsonld")
226226
```
227227
The result is available [here](https://raw.githubusercontent.com/Orange-OpenSource/python-ngsild-client/master/parking_system.jsonld).<br>
@@ -235,7 +235,7 @@ Check everything is ok by asking the broker for the number of occupied spots.<br
235235
Eventually close the client.
236236

237237
```python
238-
n = client.count("ParkingSpot", q='status=="occupied"') # 282
238+
client.count("ParkingSpot", q='refParkingSite=="urn:ngsi-ld:OffStreetParking:porto-ParkingLot-23889";status=="occupied"') # 282
239239
client.close()
240240
```
241241

0 commit comments

Comments
 (0)