Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära DataFrames | Basics
Introduction to pandas [track]
course content

Kursinnehåll

Introduction to pandas [track]

Introduction to pandas [track]

1. Basics
2. Reading and Exploring Data
3. Accessing DataFrame Values
4. Aggregate Functions

book
DataFrames

If one column is not enough and you want to store data like in a spreadsheet, then you most likely will use DataFrames.

What is DataFrame?

Pandas DataFrame is a two-dimensional, size-mutable, tabular data, that may consist of values of different types. You can think of dataframes as tables.

There are several ways of DataFrame creating. They are all based on the use of different parameters within pd.DataFrame() method. First, you can pass list of lists - this will populate the table just like nested lists look like.

123456
# Importing library import pandas as pd # Create DataFrame df = pd.DataFrame([[1, 2, 3], [4, 5, 6]]) print(df)
copy

Also you can create a DataFrame with predefined column's names. To it, pass a dictionary as the parameter. Keys of this dictionary will be the column's names and dictionary values will be respective column' values.

Dictionary is an ordered collection, that stores data in key:value format. To create a dictionary, use curly brackets, and pass key:value pairs. For instance, d = {'key1': 'value1', 'key2': 'value2'}. Dictonary values can be either strings, or numbers, or lists, or arrays.

123456
# Importing library import pandas as pd # Create DataFrame df = pd.DataFrame({'column1': [1, 2, 3], 'column2': [4, 5, 6]}) print(df)
copy

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 5

Fråga AI

expand
ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

course content

Kursinnehåll

Introduction to pandas [track]

Introduction to pandas [track]

1. Basics
2. Reading and Exploring Data
3. Accessing DataFrame Values
4. Aggregate Functions

book
DataFrames

If one column is not enough and you want to store data like in a spreadsheet, then you most likely will use DataFrames.

What is DataFrame?

Pandas DataFrame is a two-dimensional, size-mutable, tabular data, that may consist of values of different types. You can think of dataframes as tables.

There are several ways of DataFrame creating. They are all based on the use of different parameters within pd.DataFrame() method. First, you can pass list of lists - this will populate the table just like nested lists look like.

123456
# Importing library import pandas as pd # Create DataFrame df = pd.DataFrame([[1, 2, 3], [4, 5, 6]]) print(df)
copy

Also you can create a DataFrame with predefined column's names. To it, pass a dictionary as the parameter. Keys of this dictionary will be the column's names and dictionary values will be respective column' values.

Dictionary is an ordered collection, that stores data in key:value format. To create a dictionary, use curly brackets, and pass key:value pairs. For instance, d = {'key1': 'value1', 'key2': 'value2'}. Dictonary values can be either strings, or numbers, or lists, or arrays.

123456
# Importing library import pandas as pd # Create DataFrame df = pd.DataFrame({'column1': [1, 2, 3], 'column2': [4, 5, 6]}) print(df)
copy

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 5
Vi beklagar att något gick fel. Vad hände?
some-alt