Hint: You can adjust the default video playback speed in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Basic Pandas Data Structures

Give Feedback

In this lesson you’ll get an introduction into Pandas’ basic data structures: Series and DataFrame. However, this video focusses on the Pandas Series data structure.

Comments & Discussion

Bill Sewell on March 14, 2019

xrange threw me an error (name xrange is not defined), but range worked. Why would it work in your example but not mine?

Dan Bader RP Team on March 16, 2019

@Bill: That’s because this video series uses Python 2.x, and xrange is no longer available in Python 3.x, where you’d use the range function. Some more info here.

Sciencificity on March 16, 2019

Hi Dan, With Python 2.x not being supported from 2020 shouldn’t all the video tutorials on RP be for Python 3.x now? That would be really appreciated - being someone new to python I googled this to figure out why mine did not work, but my expectation going in was that I would be watching an up-to-date pandas tutorial, and then I got disappointed when I figured out it was 2.x being used, hence the error. I had similar issues with the stocks data pull and vincent (the last exercise in this tutorial) and that led me to give up and not bother googling further - and I would have really loved to complete that exercise! Thanks.

Dan Bader RP Team on March 16, 2019

shouldn’t all the video tutorials on RP be for Python 3.x now?

I agree and our upcoming tutorials will all use Python 3 :) That said, I think there’s still a benefit to having some Python 2.x specific content available, but it needs a better disclaimer at the start of the course. I’ll work on adding those!

Pucho on Dec. 7, 2019

Hi there,

Just for other people using python3.

As mentioned above, replace xrange with range. DatetimeIndex has been deprecated in favor of date_range.

import random
from pandas import date_range

# Create some random data
data = [random.randint(0,10000) for x in range (10000)]
# Create datetime Index, providing start and freq
index = date_range(start='01-01-2013', periods=len(data), freq='T')
s = Series(data, index=index)


fd on Jan. 3, 2020

as s_daily i receive just: <pandas.core.resample.DatetimeIndexResampler object at 0x11d521160> ..please advise thanks ;-)

fd on Jan. 3, 2020

problem solved, thanks

Richard Obermeier on April 26, 2020

First off here is a working snippet that works with current pieces of SW (python3, pandas):

import pandas as pd
import numpy as np
import random
from pandas import DataFrame, Series
from pandas import date_range

data = [random.randint(0,10000) for x in range(10000)]
index = date_range(start='01-01-2013', periods=len(data), freq='T')
s = Series(data, index=index)

Some more points I wanted to make

  • I doubt that the value add of a not-working tutorial compensates for the frustration and lost time of searching why it is not working
  • the expectation when coming from the other high-quality Real Python tutorials (up until now I was a big fan of it) is different. You are damaging this reputation.
  • you should at least consider putting a warning at the beginning of the tutorial and put a simple transcript there that works with the current version

dg73 on May 11, 2020

agree with Richard. Am new to Python and making basic mistakes at the best of times. To have to figure out what the 3 equiv of 2 is adds to the frustration. And for it not to be made clear in advance that this is for 2 is even worse. I paid the membership to save me time, not add to the aggro. Still trying to figure out pandas …

Become a Member to join the conversation.