When we have a data frame we can work with

the data and save the results in other formats.

Consider the stack of 13 blocks of different colors.

We can see there are three unique colors.

Let's say you would like to find out

how many unique elements are in a column of a data frame.

This may be much more difficult because instead of 13 elements,

you may have millions.

Pandas has the method unique to

determine the unique elements in a column of a data frame.

Lets say we would like to determine the unique year of the albums in the data set.

We enter the name of the data frame,

then enter the name of the column released within brackets.

Then we apply the method unique.

The result is all of the unique elements in the column released.

Let's say we would like to create a new database

consisting of songs from the 1980s and after.

We can look at the column released for songs made after 1979,

then select the corresponding columns.

We could accomplish this within one line of code in Pandas.

But let's break up the steps.

We can use the inequality operators for the entire data frame in Pandas.

The result is a series of Boolean values.

For our case, we simply specify the column

released and the inequality for the albums after 1979.

The result is a series of Boolean values.

The result is true when the condition is true and false otherwise.

We can select the specified columns in one line.

We simply use the data frames names and square brackets we placed

the previously mentioned inequality and assign it to the variable df1.

We now have a new data frame,

where each album was released after 1979.

We can save the new data frame using the method to_csv.

The argument is the name of the csv file.

Make sure you include a.csv extension.

There are other functions to save the data frame in other formats.