Skip to content

Tag: numpy

What does axis = 0 do in Numpy’s sum function?

I am learning Python, and have encountered numpy.sum. It has an optional parameter axis. This parameter is used to get either column-wise summation or row-wise summation. When axis = 0 we imply to sum it over columns only. For example, This snippet of code produces output: array([5, 7, 9]), fine. But if I do:…

Pandas: convert dtype ‘object’ to int

I’ve read an SQL query into Pandas and the values are coming in as dtype ‘object’, although they are strings, dates and integers. I am able to convert the date ‘object’ to a Pandas datetime dtype, but I’m getting an error when trying to convert the string and integers. Here…

how to calculate accuracy based on two lists python?

I have two lists. How can I calculate accuracy based on these lists? Answer This will give you the percentage that were correct – that is, the number correct over the total number. It works by calculating the number that are equal between the two lists then dividing by the total number of labels. Also n…

In numpy, what does selection by [:,None] do?

I’m taking the Udacity course on deep learning and I came across the following code: What does labels[:,None] actually do here? Answer http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html numpy.newaxis The newaxis object can be used in all slicing operations to create an axis of length one. :c…