Dictionary in Python is one of the most useful core data structures in Python. Sometimes, you may want to create a dictionary and also maintain the order of items you inserted when you are iterating the keys. Python’s collections module has OrderedDict that lets you create a ordered dictionary. Let us see an example of […]
Python
Pearson and Spearman Correlation in Python
Understanding relationship between two or more variables is at the core of many aspects of data analysis or statistical analysis. Correlation or correlation coefficient captures the association between two variables (in the simplest case), numerically. One of the commonly used correlation measures is Pearson correlation coefficient. Another commonly used correlation measure is Spearman correlation coefficient. […]
Pandas query(): How to Filter Rows of Pandas Dataframe?
Pandas offer many ways to select rows from a dataframe. One of the commonly used approach to filter rows of a dataframe is to use the indexing in multiple ways. For example, one can use label based indexing with loc function. Introducing pandas query() function, Jake VanderPlas nicely explains, While these abstractions are efficient and […]
Pandas 0.25.0 is Here. What is New? Named aggregation, explode() and sparse dataframe
If you are like me, you might have missed that the fantastic Pandas team has released the new version Pandas 0.25.0. As one would expect, there are quite a few new things in Pandas 0.25.0. A couple of new enhancements are around pandas’ groupby aggregation. Here are a few new things that look really interesting. […]
How To Slice Rows and Columns of Sparse Matrix in Python?
Sometimes, while working with large sparse matrices in Python, you might want to select certain rows of sparse matrix or certain columns of sparse matrix. As we saw earlier, there are many types of sparse matrices available in SciPy in Python. Each of the sparse matrix type is optimized for specific operations. We will see […]