O'Reilly logo

Learning pandas - Second Edition by Michael Heydt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating and using an index with a Series or DataFrame

Indexes can either be created explicitly or you can let pandas create them implicitly. Explicit creation takes place when you assign the index using the index parameter of a constructor.

The following code demonstrates by first creating a DatetimeIndex independently.

You can use this index on its own or associate it with a Series or DataFrame. This code creates a DataFrame utilizing the index.

An index can also be directly assigned to an existing DataFrame or Series by setting the .index ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required