Want to share your content on python-bloggers? click here.
Understanding who your most influential customers are—those who consistently recommend your business—is essential for sustainable, cost-effective growth. This approach, called social influencer analysis, identifies customers who act as connectors and referral hubs within your customer base. Historically, performing this type of analysis required complex Excel formulas or specialized analytics software, placing it beyond the reach of many everyday Excel users.
With Python’s NetworkX package now directly accessible inside Excel, performing sophisticated influencer analysis has become intuitive and visual. NetworkX quickly reveals referral relationships, measures influencer importance through centrality metrics, and identifies natural customer communities, giving Excel users a significant analytical advantage. Better yet, by leveraging Copilot and generative AI, you can perform this entire analysis simply by using clear, natural-language prompts.
To get started, download the exercise file below, which includes sample customer referral data you can use to practice these techniques.
Creating a referral network
Once you’ve loaded your referral data into Excel, you’re ready to visualize the network of customer referrals. Using Excel’s built-in Copilot and generative AI, you can prompt it to create a clear and intuitive network graph:
“Using NetworkX, create a directed network graph where each node is a customer, and each edge represents a referral (from referrer_customer
to referred_customer
). Visualize the graph clearly labeling all nodes.”

The resulting visualization represents customers as nodes (points), with arrows indicating the direction of referrals from one customer to another. From this directed graph, it’s easy to immediately spot key connectors (customers who refer many others, indicated by multiple outgoing arrows) as well as chains of referrals flowing through the customer network.
At a glance, you can see influential referrers like Alice, Bob, and Grace, each having multiple connections. You can also observe referral chains such as Victor → Uma → Tina → Steve, highlighting how certain customers can indirectly drive growth beyond immediate connections.
This powerful yet intuitive visualization provides immediate insights into referral behavior, identifying influential customers and potential areas to strategically encourage even more referrals.
Identifying the most influential customers
After visualizing the customer referral network, the next step is to quantify which customers are the most influential: those who directly referred the highest number of new customers. NetworkX simplifies this step by calculating out-degree centrality, a measure of how many referrals each customer made relative to the entire network.
Using Copilot, we enter the following clear and simple prompt
“Use NetworkX to calculate centrality metrics for each customer node in the referral graph. Identify the top 5 customers based on their out-degree centrality, clearly displaying each customer’s name along with their centrality score.”
The results show the five customers who are most actively referring new customers: Alice, Carol, Grace, and Bob are tied as top influencers, each with an out-degree centrality score of approximately 0.0952. This indicates these customers have made the most referrals compared to the rest of the network. Quinn also appears as an influential customer with a centrality score of about 0.0476, meaning she’s also actively contributing to customer growth.
From a business perspective, these influential customers are ideal candidates for rewards, loyalty programs, or ambassador campaigns. Recognizing and incentivizing these individuals can amplify your growth by motivating them to refer even more new customers, boosting organic growth at a relatively low cost.
Detecting customer communities
Next, we want to discover customer communities, or natural groupings within our referral network, using something called a community detection algorithm. This algorithm will analyze how customers are connected through referrals, finding groups who interact more closely with each other than with the broader network. It starts by taking our referral network (where referrals have a direction, from one customer to another) and simplifying it into connections without direction, effectively just looking at who knows who, without worrying about who referred whom first. Then it systematically identifies groups that are tightly interconnected, giving us natural segments within our customer base.
Here’s our prompt:
“Convert our directed referral graph into an undirected graph, and apply a community detection algorithm (such as Girvan-Newman from NetworkX) to identify distinct customer communities. Clearly and visualize list the customers within each detected community.”
Excel’s traditional grid can have difficulty clearly showing these community clusters, because the algorithm returns groups as Python lists rather than familiar Excel tables (DataFrames). However, when in doubt, simply ask Copilot for a visual representation.
As shown above, Copilot provided a clear, intuitive graph visually highlighting three distinct communities within the network, each identified with its own color. The blue community, for example, contains customers like Victor, Uma, Tina, Steve, Grace, and Quinn, who strongly interact with each other. Another tightly-knit group (the orange community) includes Bob, Mike, David, Ian, and John, clearly showing internal referral activity. Lastly, customers Alice, Carol, Eva, Henry, Laura, and Kate form a cohesive third (green) community.
With this visualization, it becomes straightforward to identify how your customers naturally segment themselves into groups, offering immediate insights into targeted marketing opportunities—without needing deep data science expertise.
Summarizing business insights
To wrap up our analysis, let’s ask Copilot to provide a concise summary highlighting key insights and practical recommendations:
“Provide a concise summary of insights gained from this analysis, emphasizing the most influential customers (referrer_customer
), clearly defined customer communities, and recommendations for targeted marketing campaigns.”
Copilot returns the following write-up:
Based on these insights, your marketing team should focus efforts on the key influencers identified within each customer community. By engaging and rewarding these influential referrers, your marketing messages will resonate deeply within their groups, naturally spreading through their trusted connections, ultimately increasing your campaign’s impact and effectiveness.
Conclusion
Social influencer analysis provides Excel users with a powerful yet intuitive method to uncover hidden insights within their customer referral data—insights that were traditionally locked behind specialized analytics tools.
However, as powerful as these methods are, they’re not without challenges. A significant limitation in performing this kind of analysis typically involves the initial step: collecting, cleaning, and structuring your referral data. In many organizations, referral data might be scattered across emails, customer databases, or CRM systems, each with inconsistent formats. Analysts commonly tackle these data challenges by standardizing naming conventions, automating data cleaning tasks with tools like Power Query or Python scripts, and establishing clear data-entry protocols to prevent future inconsistencies.
As a next step, consider pairing this influencer analysis with other customer data you already maintain such as demographics, purchasing history, or customer lifetime value. Integrating this additional context can provide even richer insights, allowing for more targeted and effective marketing campaigns. Finally, remember that the value of this type of analysis extends beyond just identifying your top customers. It builds organizational confidence in making data-driven decisions, empowering Excel users across the business to extract deeper value from their existing tools and data.
The post Copilot in Excel: How to do social influencer analysis with Python first appeared on Stringfest Analytics.
Want to share your content on python-bloggers? click here.