From the course: Python in Excel: Data Outputs in Custom Data Visualizations and Algorithms

Unlock this course with a free trial

Join today to access over 25,400 courses taught by industry experts.

Grouping data with the K-Means algorithm

Grouping data with the K-Means algorithm

- [Instructor] The scikit-learn, or sklearn library, is a data science AI machine learning library for running models. To make our modeling more efficient, we'll just import the k-means function from the clusters section of the sklearn library. We'll import this along with Pandas and NumPy. We already have an ETL framework in this file to create a data frame object storing the daily temperatures for Santa Barbara. We'll run this code to create the data frame. Now, let's translate our Python code into Python Excel code. We'll note in the k-means tab that we're using the k-means function from the sklearn library. Let's first reference the daily data frame object that we created in the objects tab of our workbook. So, make this a bit bigger. We'll then select to just include the columns for date, low temperature, and high temperature by chaining it to the end of our code. We also need to create a data list object to use in our k-means algorithm within Excel. We'll do so using the Python…

Contents