Friday, November 14, 2014

Converting dual level dictionary to pandas dataframe

Pandas dataframe is more like a crosstab table with rows and columns and data available at the intersection of these rows and columns. 

I am currently working on calculating Euclidean distance in order to establish collaborative model to recommend stuff based on other users ratings. More on that later. 

In this post, I am simply going to show how to convert dictionary of dictionary to a dataframe. 

Following is the code snippet to do this with a simple example:


Let us say we have dictionary of userRatings as follows:




Following is a quick code to convert this into a dataframe for easier data analysis.



No comments:

Post a Comment