shift_reporting
shift_reporting ¤
Shift-based production reporting.
Simple module for shift summaries: - Production by shift - Shift performance comparison - Shift targets and actuals
ShiftReporting ¤
ShiftReporting(
dataframe: DataFrame,
*,
time_column: str = "systime",
shift_definitions: Optional[
Dict[str, Tuple[str, str]]
] = None
)
Bases: Base
Simple shift-based production reporting.
Each UUID represents one signal: - counter_uuid: production counter - part_id_uuid: part number (optional)
Example usage
reporter = ShiftReporting(df, shift_definitions={ "day": ("06:00", "14:00"), "afternoon": ("14:00", "22:00"), "night": ("22:00", "06:00"), })
Production per shift¤
shift_prod = reporter.shift_production( counter_uuid='counter_signal', part_id_uuid='part_number_signal' )
Compare shifts¤
comparison = reporter.shift_comparison(counter_uuid='counter_signal')
Initialize shift reporter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame with timeseries data |
required |
time_column
|
str
|
Name of timestamp column (default: 'systime') |
'systime'
|
shift_definitions
|
Optional[Dict[str, Tuple[str, str]]]
|
Dictionary mapping shift names to (start, end) times Default: 3-shift operation (06:00-14:00, 14:00-22:00, 22:00-06:00) |
None
|
Example shift_definitions
{ "shift_1": ("06:00", "14:00"), "shift_2": ("14:00", "22:00"), "shift_3": ("22:00", "06:00"), }
shift_production ¤
shift_production(
counter_uuid: str,
part_id_uuid: Optional[str] = None,
*,
value_column_counter: str = "value_integer",
value_column_part: str = "value_string",
date: Optional[str] = None
) -> pd.DataFrame
Production quantity per shift.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
counter_uuid
|
str
|
Production counter UUID |
required |
part_id_uuid
|
Optional[str]
|
Part number UUID (optional, for part-specific production) |
None
|
value_column_counter
|
str
|
Column containing counter values |
'value_integer'
|
value_column_part
|
str
|
Column containing part numbers |
'value_string'
|
date
|
Optional[str]
|
Specific date in 'YYYY-MM-DD' format (optional) |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with production by shift: |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
Example
shift_production('counter', part_id_uuid='part_id') date shift part_number quantity 0 2024-01-01 shift_1 PART_A 450 1 2024-01-01 shift_2 PART_A 425 2 2024-01-01 shift_3 PART_A 380
shift_comparison ¤
shift_comparison(
counter_uuid: str,
*,
value_column_counter: str = "value_integer",
days: int = 7
) -> pd.DataFrame
Compare shift performance over recent days.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
counter_uuid
|
str
|
Production counter UUID |
required |
value_column_counter
|
str
|
Column containing counter values |
'value_integer'
|
days
|
int
|
Number of recent days to analyze (default: 7) |
7
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with shift comparison: |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
Example
shift_comparison('counter', days=7) shift avg_quantity min_quantity max_quantity std_quantity days_count 0 shift_1 445 420 465 15.2 7 1 shift_2 430 405 450 12.8 7 2 shift_3 385 360 410 18.5 7
shift_targets ¤
shift_targets(
counter_uuid: str,
targets: Dict[str, float],
*,
value_column_counter: str = "value_integer",
date: Optional[str] = None
) -> pd.DataFrame
Compare actual production to shift targets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
counter_uuid
|
str
|
Production counter UUID |
required |
targets
|
Dict[str, float]
|
Dictionary mapping shift names to target quantities |
required |
value_column_counter
|
str
|
Column containing counter values |
'value_integer'
|
date
|
Optional[str]
|
Specific date in 'YYYY-MM-DD' format (optional) |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with target comparison: |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
Example
shift_targets('counter', targets={'shift_1': 450, 'shift_2': 450, 'shift_3': 400}) date shift actual target variance achievement_pct 0 2024-01-01 shift_1 445 450 -5 98.9 1 2024-01-01 shift_2 465 450 15 103.3 2 2024-01-01 shift_3 390 400 -10 97.5
best_and_worst_shifts ¤
best_and_worst_shifts(
counter_uuid: str,
*,
value_column_counter: str = "value_integer",
days: int = 30
) -> Dict[str, pd.DataFrame]
Identify best and worst performing shifts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
counter_uuid
|
str
|
Production counter UUID |
required |
value_column_counter
|
str
|
Column containing counter values |
'value_integer'
|
days
|
int
|
Number of recent days to analyze (default: 30) |
30
|
Returns:
| Type | Description |
|---|---|
Dict[str, DataFrame]
|
Dictionary with: |
Dict[str, DataFrame]
|
|
Dict[str, DataFrame]
|
|
Example
results = best_and_worst_shifts('counter') results['best'] date shift quantity 0 2024-01-15 shift_2 495 1 2024-01-18 shift_1 490 2 2024-01-22 shift_2 485