40. Removing duplicate data in NumPy and Pandas

Both NumPy and Pandas offer easy ways of removing duplicate rows. Pandas offers a more powerful approach if you wish to remove rows that are partly duplicated.

NumPy

With numpy we use np.unique() to remove duplicate rows or columns (use the argument axis=0 for unique rows or axis=1 for unique columns). Continue reading “40. Removing duplicate data in NumPy and Pandas”

34. Iterating through columns and rows in NumPy and Pandas

Using apply_along_axis (NumPy) or apply (Pandas) is a more Pythonic way of iterating through data in NumPy and Pandas (see related tutorial here). But there may be occasions you wish to simply work your way through rows or columns in NumPy and Pandas. Here is how it is done. Continue reading “34. Iterating through columns and rows in NumPy and Pandas”