Skip to main content

Pandas: Notes

Pandas Logo - Source: https://upload.wikimedia.org/wikipedia/commons/thumb/e/ed/Pandas_logo.svg/1200px-Pandas_logo.svg.png

Pandas is a Python library used for working with data sets. Pandas is derived from 'panel data' term.

https://pandas.pydata.org/ - Python Data Analysis Library.

Keyword: Dataframe

# Install pandas
python -m pip install pandas

pd.head()
pd.describe()
pd.info()

pd.read_csv()
pd.read_excel()
pd.read_json()
pd.read_html()
pd.read_sql()
pd.read_pickle()

Dataframe functions

loc and iloc functions

    loc: name/lable index
    iloc: number index

Dataframe methods

Work with Excel files

# import pandas as pd
pd.read_excel("data.xlsx")
pd.ExcelFile("data.xlsx")

Work with CSV file

import pandas as pd
import sys

def usage():
    """Print syntax"""
    print("Usage: ", sys.argv[0], "<path-to-csv-file>")

def main():
    if len(sys.argv) != 2:
        usage()
        sys.exit(1)
    
    filename = sys.argv[1]
    signin = pd.read_csv(filename)
    print(signin.info())
    print(signin.head())
    print(signin.tail())

if __name__ == "__main__":
    main()

Courses

Data Manipulation with pandas | DataCamp

References

>>> Pandas Cheatsheet

>>> Pandas Tutorial

Popular posts from this blog

GNS3: Notes

As usual, notes is for myself and might be useful and also save time for beginners start using GNS3 .

Linux: compound commands

command1 ; command2 ; command3 command1 is executed, then command2, and then command3 command1 && command2 && command3 command2 is executed only if command1 run successfully (exit code is 0), command3 is executed only if command2 run successfully (exit code is 0) command1 || command2 || command3 command2 is executed only if command1 exit code is 0 (failure), command3 is executed only if command2 exit code is 0 (failure)

Commonly used shortcut keys

Learn and use common shortcuts. Shortcuts for all Windows applications Shortcut Action CTRL + C Copy CTRL + X Cut CTRL + V Paste CTRL + Z Undo Shortcuts in Microsoft Outlook Shortcuts in Microsoft Outlook Shortcut Action CTRL + Q Mark as read CTRL + SHIFT + K New task CTRL + SHIFT + J New journal Shortcuts in notepad++ Shortcuts in notepad++ Shortcut Action CTRL + L Delete current line CTRL + Q Comment block Shortcuts in Google Docs, Google Sheets Shortcuts in Google Docs, Google Sheets Shortcut Action CTRL + / Display keyboard shortcuts