# PMS_GROUPNMI

> Describe the NMIs that a group uses to provide its service

## Column Schema

### GROUPNMIID

> Record Identifier of the NMI within a Group. When data is updated, existing record identifier is terminated, and new record identifier(s) are allocated.

SQL Type: `NUMBER(20,0)`
Polars Type: `pl.Int128`

This column is mandatory, and a primary key.

### APPROVEDDATE

> Date which this record was approved

SQL Type: `TIMESTAMP(3)`
Polars Type: `pl.Datetime()`

This column is not mandatory.

Unlike most datetime columns, this one includes a millisecond component.
e.g. `2029/03/15 00:00:00.123`.

### BASELINEMETHODOLOGYID

> Baseline methodology to be used for the PoL and Baseline assessment of the NMI

SQL Type: `VARCHAR2(50)`
Polars Type: `str`

This column is not mandatory.

### ENDDATE

> Date for which this version is effective to. Will be set to current day plus one if it is the current active record or past date if the record has been superseded/ended.

SQL Type: `TIMESTAMP(3)`
Polars Type: `pl.Datetime()`

This column is not mandatory.

Unlike most datetime columns, this one includes a millisecond component.
e.g. `2029/03/15 00:00:00.123`.

### GROUPID

> Group id of the Group which the NMI belongs in.

SQL Type: `NUMBER(20,0)`
Polars Type: `pl.Int128`

This column is not mandatory.

### LASTCHANGED

> Date time which record was last changed

For more information, see the [dedicated documentation page](../../guide/querying.md#deduplication).

SQL Type: `TIMESTAMP(3)`
Polars Type: `pl.Datetime()`

This column is not mandatory.

Unlike most datetime columns, this one includes a millisecond component.
e.g. `2029/03/15 00:00:00.123`.

### MRC

> Maximum responsive component for the NMI

SQL Type: `NUMBER(10,3)`
Polars Type: `pl.Float64`

This column is not mandatory.

### MRCREASON

> Reason for the MRC

SQL Type: `VARCHAR2(500)`
Polars Type: `str`

This column is not mandatory.

### NERRGROUPPREMISES

> Specifies whether NMI is in a NERR aggregated premises (TRUE = 1/FALSE = 0)

SQL Type: `NUMBER(1,0)`
Polars Type: `pl.Int8`

This column is not mandatory.

### NMI

> National Meter Identifier linked to the group.

SQL Type: `VARCHAR2(20)`
Polars Type: `str`

This column is not mandatory.

### RETAILCUSTOMER

> Retail customer of the NMI

SQL Type: `VARCHAR2(50)`
Polars Type: `str`

This column is not mandatory.

### SITENAME

> Site name

SQL Type: `VARCHAR2(50)`
Polars Type: `str`

This column is not mandatory.

### STARTDATE

> Effective date of when this service started operation

SQL Type: `TIMESTAMP(3)`
Polars Type: `pl.Datetime()`

This column is not mandatory.

Unlike most datetime columns, this one includes a millisecond component.
e.g. `2029/03/15 00:00:00.123`.

### SUSPENDED

> Indicates whether the NMI has been suspended from use. (TRUE = 1/FALSE = 0)

SQL Type: `NUMBER(1,0)`
Polars Type: `pl.Int8`

This column is not mandatory.

### UNAVAILABLE

> Indicates whether the NMI is unavailable for use. (TRUE = 1/FALSE = 0)

SQL Type: `NUMBER(1,0)`
Polars Type: `pl.Int8`

This column is not mandatory.

### VERSIONFROM

> Date for which this version is effective from

SQL Type: `TIMESTAMP(3)`
Polars Type: `pl.Datetime()`

This column is not mandatory.

Unlike most datetime columns, this one includes a millisecond component.
e.g. `2029/03/15 00:00:00.123`.

### VERSIONTO

> Date for which this version is effective to. Will be set to current day plus one if it is the current active record or past date if the record has been superseded/ended.

SQL Type: `TIMESTAMP(3)`
Polars Type: `pl.Datetime()`

This column is not mandatory.

Unlike most datetime columns, this one includes a millisecond component.
e.g. `2029/03/15 00:00:00.123`.

## New Data Timing

> When the NMIs are created or updated

## Code Examples

### Polars

Explicitly listing every column, casting to enums, categoricals etc is not essential, but may speed up parsing.
Swapping `int` for `pl.UInt16`, `pl.Int32` would also speed up parsing. However some of the datatypes are inferred, so they may be wrong.

This code deduplicates for you.
Deduplication is normally only required across multiple months.

This code assumes that all columns are present, which may not be true for older files.

```python
import polars as pl
import polars.selectors as cs

# for "TIMESTAMP" columns
# Note that Polars uses slightly different format strings for fractional seconds to `dt.strptime`
# e.g. "2029/03/15 00:00:00.123".
dt_ms_fmt = "%Y/%m/%d %H:%M:%S%.3f"

csv_paths = ["SOMEFILE.CSV", "OTHERFILE.CSV"]

lf = (
    pl.concat(
        [
            pl.scan_csv(
                csv_path,  # must be unzipped beforehand
                skip_rows=1,  # skip the header
                infer_schema=False,  # much faster
            )
            .filter(cs.by_index(0) == "D")  # drop the footer
            .select(~cs.by_index(range(4)))  # drop metadata columns
            for csv_path in csv_paths
        ],
        how="diagonal_relaxed",
    )
    .with_columns(
        pl.col(
            "APPROVEDDATE",
            "ENDDATE",
            "LASTCHANGED",
            "STARTDATE",
            "VERSIONFROM",
            "VERSIONTO",
        ).str.strptime(pl.Datetime, dt_ms_fmt),
    )
    .cast(
        {
            "GROUPNMIID": int,  # or pl.Int128
            "BASELINEMETHODOLOGYID": str,
            "GROUPID": int,  # or pl.Int128
            "MRC": pl.Float64,
            "MRCREASON": str,
            "NERRGROUPPREMISES": int,  # or pl.Int8
            "NMI": str,
            "RETAILCUSTOMER": str,
            "SITENAME": str,
            "SUSPENDED": int,  # or pl.Int8
            "UNAVAILABLE": int,  # or pl.Int8
        }
    )
    # Deduplicate
    # We want one row per ['GROUPNMIID']
    # Tie-breaker: greatest value of ['GROUPID', 'NMI']
    .sort(["GROUPID", "NMI"], descending=False)
    .unique(subset=["GROUPNMIID"], keep="last")
)

```

### Nemosis

This table is not yet available in [Nemosis](https://github.com/UNSW-CEEM/NEMOSIS/#static_table).

## Availability

Visibility: Private

This table is not available in the public monthly [MMSDM archive](https://www.nemweb.com.au/Data_Archive/Wholesale_Electricity/MMSDM/).
Is is only available to registered market participants over FTP inside a VPN.

## Deduplication and PDR Loader Configuration

The primary keys are:

- [`GROUPNMIID`](#groupnmiid)

The transaction type is ["UPDATE-INSERT"](https://di-help.docs.public.aemo.com.au/Content/pdrLoader/How_it_works.htm?TocPath=pdrLoader%7CAbout+pdrLoader%7C_____5#UPDATEINSERT), which means that you will likely see duplicate data with different values.

You should deduplicate by sorting based on `LASTCHANGED`, within each group of primary keys.

[PDR Loader configuration](https://nemweb.com.au/Reports/Current/MMSDataModelReport/PDRCONFIG/PROD_PUBLIC_PDR_CONFIG_FULL.zip) is:

| Report Name | Report Subtype | Version |
|---------------|-------------------|-----------|
| PARTICIPANT_REGISTRATION | PMS_GROUPNMI  | 1 |

This means that the CSV files start with metadata columns:

```csv
I,PARTICIPANT_REGISTRATION,PMS_GROUPNMI,1,...
D,PARTICIPANT_REGISTRATION,PMS_GROUPNMI,1,...
```

`ROW_FILTER_TYPE` is LASTCHANGED

## Indexes

- [`GROUPID`](#groupid)

- [`NMI`](#nmi)

## Links

[This page as JSON](../json/tables/PMS_GROUPNMI/bespoke.json) (schema documented [here](https://gitlab.com/MatthewDavis/mms-schema/-/blob/master/schema.py?ref_type=heads), but may change)

Download a [JSON Schema](../json/tables/PMS_GROUPNMI/json-schema.json) specification for this table.

[Official AEMO schema documentation](https://nemweb.com.au/Reports/Current/MMSDataModelReport/Electricity/ElectricityDataModelReport_files/Elec44.htm#219)

## Other Information

Package: [PARTICIPANT_REGISTRATION](../packages/PARTICIPANT_REGISTRATION.md)
