Data Processing with Python and R
Data Processing with Python and R
Data Processing with Python and R
Python is a high-level, general-purpose programming language known for its simplicity and
versatility. It is widely used for data processing, analysis, and visualization. Below are the
foundational topics:
• Data Types:
• Primitive: int, float, str, bool
• Composite: list, tuple, dict, set
• Basic Operations:
• Arithmetic (+, -, *, /, //, %)
• Relational (==, !=, <, >, <=, >=)
• Logical (and, or, not)
• Control Structures:
• Conditional Statements: if, elif, else
• Loops:
• for: Iterates over a sequence.
• while: Executes as long as a condition is true.
• Functions:
• Definition: def function_name(parameters):
• Return values with return
• Example:
• Modules:
• Importing libraries: import math, from random import randint
• Reusing code from external Python files.
1. Local Data:
• File operations: Reading and writing files.
import requests
response = requests.get("http://example.com/data")
print(response.text)
1. Sequences:
• Strings: Immutable sequences of characters.
• String slicing: text[0:5]
• Lists: Mutable ordered collections.
• Example: my_list = [1, 2, 3]
• Tuples: Immutable ordered collections.
• Example: my_tuple = (1, 2, 3)
2. Basic Data Presentation:
• Example: Reading a CSV file and presenting data in tabular format.
3.1 Matplotlib
• Customizations:
• Titles, labels, legends, colors, and line styles.
my_set = {1, 2, 3, 4, 4}
import numpy as np
arr = np.array([1, 2, 3])
import pandas as pd
series = pd.Series([1, 2, 3], index=["a", "b", "c"])
df.fillna(0, inplace=True)
• Removing duplicates:
df.drop_duplicates(inplace=True)
• Basic statistics:
df.describe()
• Correlation:
df.corr()
• Grouping data:
df.groupby("column_name").mean()
• Filtering data:
• Key Concepts:
• Abstraction: Hiding details to simplify usage.
• Inheritance: Creating new classes from existing ones.
• Encapsulation: Bundling data with methods.
• Example:
class Animal:
def __init__(self, name):
self.name = name
class Dog(Animal):
def bark(self):
return f"{self.name} says Woof!"
import tkinter as tk
root = tk.Tk()
label = tk.Label(root, text="Hello, World!")
label.pack()
root.mainloop()
7.1 Basics of R