Counting Frequency of Two Words in Job Titles

Abstract: Count unique job titles containing specific keywords using Excel helper columns or Python pandas boolean masks.

Created: 2026-09-17 by
To count the frequency of two specific words in a list of job titles, you can use Excel formulas, Python scripts, or command-line tools depending on your operating system and data volume. For small datasets, Excel's COUNTIF function is efficient, while larger lists benefit from Python's pandas library or Unix grep commands for speed and automation.

Using Excel for Small Datasets

If your job titles are stored in a spreadsheet and the dataset is manageable (under 100,000 rows), Microsoft Excel provides a straightforward solution without requiring programming knowledge. The COUNTIF function allows you to search for a specific text string within a range of cells. To count the occurrences of a single word, such as "Manager," in column A, you would use the formula =COUNTIF(A:A, "*Manager*"). The asterisks act as wildcards, ensuring that the word is found even if it appears as part of a longer title like "Senior Project Manager." When you need to count the frequency of two different words simultaneously, you cannot simply add two COUNTIF results because this might double-count entries containing both words. Instead, you should use the COUNTIFS function with an OR logic workaround or use multiple helper columns. A more robust approach involves creating a helper column that flags each row if it contains either word. For example, in cell B2, you could enter =IF(OR(ISNUMBER(SEARCH("Manager",A2)), ISNUMBER(SEARCH("Director",A2))), 1, 0). Dragging this formula down the column creates a binary indicator for every job title. Summing this helper column with =SUM(B:B) gives you the total number of unique job titles containing at least one of the specified words. This method ensures accuracy by treating each row as a distinct entity rather than counting individual word occurrences across all text. For users who prefer a single formula without helper columns, array formulas can be used, though they are slower on large datasets. In modern versions of Excel, you can use =SUM(--(ISNUMBER(SEARCH({"Manager","Director"}, A2:A100)))), but note that this counts total word appearances, not unique rows. If you need unique row counts, the helper column method remains the most reliable standard practice for office environments.

Automating with Python and Pandas

For datasets exceeding the capacity of Excel or when you need to integrate this analysis into a larger data pipeline, Python offers superior performance and flexibility. The pandas library is the industry standard for tabular data manipulation. After importing your data using pandas.read_csv(), you can create boolean masks to identify rows containing your target words. First, ensure your job title column is treated as strings. Then, use the str.contains method to check for the presence of keywords. To count the frequency of two words appearing together in any order, you can combine conditions using bitwise operators. For instance, to find how many jobs contain both "Data" and "Scientist," you would write:
import pandas as pd

df = pd.read_csv('job_titles.csv')
mask_data = df['Title'].str.contains('Data', case=False, na=False)
mask_scientist = df['Title'].str.contains('Scientist', case=False, na=False)
count_both = len(df[mask_data & mask_scientist])
This code snippet demonstrates how to handle case-insensitivity (case=False) and missing values (na=False), which are common issues in real-world HR data. If you want to count rows that contain either word, you would use the bitwise OR operator (|) instead of AND (&). Python processes these operations in C-optimized loops, making it significantly faster than Excel for millions of records. Additionally, this approach allows for easy extension; you can store the results in a new DataFrame or export them directly to a CSV file for further reporting.

Command-Line Solutions for Linux and macOS

Users working in terminal-heavy environments or those analyzing log files and exported text dumps can leverage Unix-like command-line tools. The grep utility is designed for searching plain-text data sets for lines that match a regular expression. To count the occurrences of a single word in a file named titles.txt, you can pipe the output to wc -l (word count lines). The command grep -i "Manager" titles.txt | wc -l will return the number of lines containing "Manager," ignoring case due to the -i flag. Counting two words requires a slightly more complex regex pattern. To find lines containing either "Manager" or "Director," you can use extended regular expressions with grep -E. The command grep -E -i "(Manager|Director)" titles.txt | wc -l searches for lines matching either term. If you need to find lines containing both words, you can chain commands using pipes: grep -i "Manager" titles.txt | grep -i "Director" | wc -l. This first filters for "Manager" and then filters those results for "Director," ensuring only lines with both terms are counted. For Windows users, PowerShell provides similar capabilities. You can use the Select-String cmdlet to search for patterns. The command (Select-String -Path "titles.txt" -Pattern "Manager|Director" -CaseSensitive:$false).Count returns the number of matching lines. While the syntax differs, the logical approach remains consistent across platforms: filter the text based on pattern matching and count the resulting lines.

Data Cleaning Considerations

Regardless of the tool you choose, the accuracy of your frequency count depends heavily on data quality. Job titles often contain variations such as "Sr. Manager," "Senior Manager," or "Manager, Sales." Simple string matching may miss these variations if you are only searching for "Manager." It is crucial to decide whether you want exact matches or substring matches. Using wildcards in Excel or regex patterns in Python/CLI helps capture these variations. Furthermore, consider duplicate entries. If the same person has multiple job titles listed in the database, they might be counted multiple times. Depending on your goal, you may need to deduplicate the dataset before counting. This often involves grouping by employee ID and selecting the most recent or primary title. For more complex data cleaning tasks, such as merging multiple text files or extracting specific parts from unstructured data, specialized techniques are required. You might find it useful to explore methods for merging multiple text files to consolidate sources before analysis. Similarly, understanding how to sum values based on unique identifiers can help in aggregating related metrics after identifying the relevant job titles.

Frequently Asked Questions

What if my job titles have different capitalizations?

You should always use case-insensitive matching options. In Excel, COUNTIF is inherently case-insensitive. In Python, set case=False in str.contains. In CLI tools, use the -i flag with grep or -CaseSensitive:$false in PowerShell.

How do I count words that appear in any order within a title?

Standard substring search functions like SEARCH or str.contains automatically detect substrings regardless of their position within the string. They do not require the word to be at the start or end, so "Senior Data Scientist" and "Data Scientist Senior" will both be matched correctly.

Can I count the frequency of three or more words?

Yes. In Excel, you can extend the OR statement inside the IF function to include additional conditions. In Python, you can chain multiple boolean masks using & for AND logic or | for OR logic. In CLI, you can chain multiple grep commands or use more complex regex patterns with -E.

What should I do if the dataset is too large for Excel?

Move to Python with pandas or a database query language like SQL. Excel struggles with datasets over 1 million rows due to memory constraints. Python handles large files efficiently by processing data in chunks or using optimized C-extensions, while SQL databases are designed for rapid querying of massive tables.

How can I avoid counting partial matches like "Managers" when searching for "Manager"? Both are valid counts.

If you want to count plural forms, ensure your search term is a substring. COUNTIF and str.contains treat "Manager" as a substring, so "Managers" will be included. If you strictly want exact word boundaries, you must use regular expressions with word boundary markers (\b) in Python or advanced regex in CLI tools, but this is rarely necessary for general job title analysis.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More