I am trying to plot the number of unique values in a column containing strings on the y axis as follows:
alt.Chart(as_df).mark_bar(color='firebrick').encode(
alt.X('TimeUTC:T', title='Day',axis=alt.AxisConfig(labelAngle=45)),
alt.Y('distinct(FlightID)', type='nominal', title='Number of flights')
)
My data is of the form:
| TimeUTC | FlightID | Latitude | Longitude |
|---|---|---|---|
| 2021-01-01 06:05:00.079745+00:00 | 2021-01-01 06:05:00+00:00 | a706014b-02d0-424a-a346-2bd25ffa8e08 | 42.3323 |
| 2021-01-01 06:05:00.291337+00:00 | 2021-01-01 06:05:00+00:00 | d2e2bd67-c95a-426d-9357-a717d6c9124d | 42.3434 |
| 2021-01-01 06:06:00.131817+00:00 | 2021-01-01 06:06:00+00:00 | a706014b-02d0-424a-a346-2bd25ffa8e08 | 42.3323 |
| 2021-01-01 06:06:00.219178+00:00 | 2021-01-01 06:06:00+00:00 | d2e2bd67-c95a-426d-9357-a717d6c9124d | 42.3434 |
The result is this chart:
If I count the number of unique FlightIDs on Feb 9th, I get:
foo = as_df['20210209':'20210209']
foo.FlightID.nunique()
58
Why is the chart showing a maximum number of unique FlightIDs as 12 when there is at least one day with 58?
python: 3.9.7 altair: 4.1.0
