My Coding >
Programming language >
Python libraries and packages >
Python Panda (Page: 2)
Go to Page:
Pandas DataFrame is a two dimensional array (table structure), where each column is made of Pandas Series. Columns can be different type. DataFrame has column and row names for easy search and access to the stored data.
Pandas DataFrame is a two dimensional table and many operations can be performed along row or columns. To specify the direction of this operation, you can use parameter axis equal 0 for rows and 1 for columns
Different ways to create Pandas DataFrame
There are a lot of different ways to create Pandas DataFrame. Here I will try to describe most important of them. Column and row names can be generated automatically, or can be declared by keywords columns and index, respectively.
Creating empty Panda DataFrames
Concatenation of series
DataFrame is a collection of Series and this is very logical, that DataFrame can be created via concatenation of few Series. During this concatenation, it is always important to remember about behaviour in the case of concatenation of different size objects
By using constructor with series or lists to columns
It is possible to create DataFrame with constructor from series or lists with the same operation. Please note, if you use lists – they should be the same length!!!
Creating Pandas DataFrame from lists of lists or tuples
List of lists can be converted to DataFrame with constructor. List of lists can be done with zipping of two lists
Creating of DataFrame from dictionaries
In this example we will create DataFrame from a list of dictionaries. Keys will be used as a column names. And rows we will index with our names
Creating of DataFrame from NumPy array
DataFrame can be converted from 2 dimensional NumPy array. And also we will give names for rows and columns
Last 10 artitles
9 popular artitles
|© 2020 MyCoding.uk -My blog about coding and further learning. This blog was writen with pure Perl and front-end output was performed with TemplateToolkit.|