Re: [Numpy-discussion] [SciPy-User] Why slicing Pandas column and then subtract gives NaN?
Thanks a lot, Thomas.
I don’t have index when I read in the data. I just want to slice two series to the same length, and subtract. That’s it!
I also don’t what numpy methods wrapped within methods. They work, but hard do understand.
How would you do it? In Matlab or R, it’s very simple, one line.
________________________________
From: SciPy-User
Isn't Numpy built on top of Pandas?
It's the other way round: pandas is built on Numpy. Pandas indices are an extra layer of functionality on top of what Numpy does.
On Thu, 14 Feb 2019 at 20:22, C W
a = pd.Series([85, 86, 87, 86]) b = pd.Series([15, 72, 2, 3]) a[1:4]-b[0:3] 0 NaN 1 14.0 2 85.0 3 NaN type(a[1:4])
Example 2: worked If I use values() method, it's converted to a Numpy object. And it works!
a.values[1:4]-b.values[0:3] array([71, 15, 84]) type(a.values[1:4])
What's the reason that Pandas in example 1 did not work? Isn't Numpy built on top of Pandas? So, why is everything ok in Numpy, but not in Pandas? Thanks in advance! _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.orgmailto:NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion _______________________________________________ SciPy-User mailing list SciPy-User@python.orgmailto:SciPy-User@python.org https://mail.python.org/mailman/listinfo/scipy-user _______________________________________________ SciPy-User mailing list SciPy-User@python.orgmailto:SciPy-User@python.org https://mail.python.org/mailman/listinfo/scipy-user
participants (7)
-
Andras Deak
-
C W
-
Daniele Nicolodi
-
Juan Nunez-Iglesias
-
Mike C
-
Paul Hobson
-
Robert Kern