Legacy – Creating a DataFrame Workout
- 02:07
Workout demonstrating how to create a DataFrame in Python using the PyCharm IDE.
Glossary
Creating a DataFrame Dataset Pandas LibraryTranscript
We can certainly create a whole data set or even a DataFrame in Python from scratch rather than importing the CSV file. In order to do that, we use the pandas library. Before we create a DataFrame, we have to do the basic step of importing the pandas. Now, let us say we named the DataFrame as DF. And this would be equal to PD . data frame is the command that we use to create a DataFrame in Python using the pandas, we open brackets. Let us say we want two columns A B with three different rows. To do that, we need the curly brackets and the first column name a should go in double quotations. And then we have really to enter the three different values that goes into the column A, let's say it one, two, and three. Now our second column B needs to again go and liquidations at that let's say the values of the second column are four, five and six. In case we want to include an index naming or include indexing for this two columns, and the two three rows, we say index equals one to entry. Now we just have to run the command. Perfect, there aren't any errors returned. Now in order to view the actual DataFrame, we say print DF and run the code. Perfect. That's how our DataFrame would look like. It's got two columns A B, and three indexing of the rows 1,2, 3. Where Column A has values 1, 2, 3 And column B has values 4, 5, 6