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

nmap - The Network Mapper

WARNING : It is ILLEGAL to scan hosts without permission.

VMware Workstation: vmrun.exe

Using vmrun.exe to manage VMs on VMware Workstation

Linux command: lspci

Linux command: lspci - list pci devices tuyendq@ubuntu001:~$ man lspci NAME        lspci - list all PCI devices SYNOPSIS        lspci [options] DESCRIPTION        lspci is a utility for displaying information about PCI buses in the system and devices connected to them.        By  default,  it  shows a brief list of devices. Use the options described below to request either a more verbose output or output intended for parsing by        other programs.        If you are going to report bugs in PCI device drivers or in lspci itself, please include output of "lspci -vvx" or even better  "lspci  -vvxxx"  (however,        see below for possible caveats).        Some  parts of the output, especially in the highly verbose modes, are probably intelligible only to experienced PCI hac...