How to Detect More Data Patterns with Numpy Reduce

A step by step guide to use pandas in exploratory data analysis

If you want to add (or multiply) only those elements of a column which meet certain conditions with another column, then Numpy Reduce is a good choice.

This method is very handy and instrumental in detecting suspicious data patterns by analyzing the influence of one column over the other at an early stage.

Let’s see how we can use it in troubleshooting mechanical problems. Implemented this for a client who performs Machine Health Monitoring Services in the automotive industry.

Photo by Joshua Mayo on Unsplash

Domain Notes

For those who are new to the vibration analysis field, here is a quick overview.

What is machine health monitoring?

In general, from chocolate to an aircraft, anything that is produced in a factory needs several machines to operate in synergy. However, if a particular machine in the critical path goes down it affects the complete chain of production. As a result, it incurs a huge loss to the company. So, it is very important to keep monitoring the health of each machine.

As a matter of fact, many kinds of machines like grinding machines, compressors, or refiners keep producing some vibrations while they are running.

Machine health monitoring aims at predicting the faults of a machine before they occur. All in all, this stream of science periodically checks the machine conditions, analyses the data and predicts the failures.

What is vibration analysis?

When humans feel sick, they express their pain by voice to alert others and to communicate with a doctor. But how can machines do that? Of course, they too follow a similar way.

When there is a problem developing inside a machine, the machine expresses it by making different(abnormal) sounds/vibrations. Following that, a team of experts would analyze these vibrations to detect the nature and cause of the fault.

Vibration analysis is a growing field of data analytics. It has great potential in driving the early detection of machine failures and saving enormous failure costs.

What do the field engineers do?

Our field engineers love the machines like pets. They regularly visit the factories, read the machine condition send that data to our analytics team.

Basically, they use the devices like a vibrometer or an accelerometer and read the machine vibrations. In effect, these devices translate the vibrations into various mechanical attributes like velocity, acceleration, RPM of a machine.

What does the data analytics team do?

Well, the data engineers at the data analytics team enrich the attributes of the datasets. As soon as they receive the datasets from the field engineer, the data engineers transform the machine readings into more statistical measurements. And the enriched data can be easily interpreted by business analysts.

What do the business analysts do?

Here the business analysts are typically mechanical engineers. They understand well about the machine internals. From the statistics reported by the data analytics team, they determine the problem location. Subsequently, they prescribe the corrective action.

Business Scenario

A healthy machine exhibits normal behavior even when the stress levels are high. If the health deteriorates then the vibrations will be different at various stress levels.

As per the business analysts, amplitude is an indicator of machine stress. If the machine is healthy then the frequency will not drop significantly at a higher amplitude.

To be specific, if the average frequency at a high amplitude is significantly less than the average frequency at a low amplitude then we can say that the machine is developing some problems.

The module should support the analysts to filter based on the amplitude column and then calculate the average of the resultant frequency column.

Let’s see how we can solve it using the Numpy Reduce method.


  1. Firstly, read the frquency and amplitude values from the vibrations data.
  1. The amplitude here varies from 1.5 to 2.4. Let’s calculate the average frequency when the amplitude is less than 1.8.

Numerator: The np.add.reduce method adds all the frequencies that qualify the where condition.

Denominator: Similarly adds the numeric value 1 for every record that qualifies the where condition. Logically it’s equivalent to the number of records qualifying the where condition.

The average value of the frequencies qualifying the where condition = Numerator / Denominator. It’s arrived at 35.75.

3. Now let’s calculate the same when the amplitude is at a high range. That is above 2.2.

Now the value shows 34.45. There is a significant drop in the frequency.


The business team has arrived at a conclusion that a clear drop of more than 1Hz in the frequency at higher amplitude indicates that the machine is developing some problems when the stress is more. The internal components are not able to oscillate at the expected level.


We have read the frequency and amplitude details of a machine from its vibrations. Then used the Numpy Reduce method, sum up the frequencies at different amplitude ranges. That made a pattern evident with the amplitudes. Found that the machine components are oscillating well at the lower load but declining to oscillate when the load increased. As this analysis indicates a possible problem being developed, the machine has been suggested for in-depth audit by the engineering team.

What Next?

If you would like to share your business case on how you’ve used this method, please send the details to Our editorial team shall get back to you in adding it to this publication. Please contribute to the integration of knowledge towards building a new generation of fast learners. An example speaks a thousand paragraphs.

Also Read

An Excellent Method for Instant Data Transformation, DF GroupBy Transform

How is GroupBy Rank used in Pricing Intelligence?

Write a Comment