首页 > > 详细

讲解 Python Applications for Business讲解 留学生Python程序

Python Applications for Business

•     Exam II is an in-class exam. Exams will be “Open Book," but you can only make full use of the materials from this class on the Course Site. Sharing information with others or using other resources (e.g., ChatGPT, Gemini, Google, email, text messages, etc.) will be considered as CHEATING.

•    The exam will be available on Course Site under the Exam folder. Exam I will be administered Wednesday, Nov 12, and you will have 75 mins to take the exam.

•    There is only one part to the Exam. The structure is very similar to our workshop, i.e., It will include one dataset with about 5 to 7 tasks, from data cleaning/management to data visualization, and one optimization modeling, each containing multiple questions, all to be completed in Google Colab. Please review lecture slides and lab practice questions for preparation. Solutions for each lab will be provided.

•     Please make sure to submit your exam on time. Late submission will result in a grade reduction.

What We Have Covered

Data analysis 1: DataFrame Basics

1. Creating Your Own DataFrame

•    Adding new columns and rows

•     Modifying existing data within a DataFrame.

2. Subsetting & Filtering with DataFrame

•     Indexing and selecting data by label (.loc) and by position (.iloc)

•     Conditional filtering with multiple conditions

•     Selecting specific columns or rows

3. Handling Null Values

•     Detecting missing values with .isna() and .notna()

•     Removing null values with .dropna()

Replacing null values with .fillna() and using forward/backward fill

4. Data Transformation and Cleaning

•     Removing duplicates with .drop_duplicates()

•     String manipulation with .str accessor (e.g., lowercase, replace)

•     Renaming columns and indexes with .rename()

•     Identify and filter out extreme values

5. Data Aggregation and Grouping

•     Grouping data with .groupby() and performing aggregate functions (mean, sum, etc.)

6. Descriptive Statistics and Data Analysis

•     Basic statistics (mean, median, mode, standard deviation) with .describe()

•     Correlation matrix

•    Applying custom functions to DataFrames with .apply() and lambda

7. Time Series Data: Handling datetime data (converting to datetime, extracting year/month/day)

Data analysis 2: Data visualization with Matplotlib, seaborn and plotly

1.    Matplotlib (matplotlib.pyplot)

•     plot() – Line plot

•     pie() – Pie chart

•     boxplot() – Box plot

•    title() – Adding a title

•    xlabel(), ylabel() – Labeling axes

•     legend() – Adding a legend

2.    Seaborn

•     scatterplot() – Scatter plot

•     histplot() – Histogram

•     boxplot() – Box plot

•     heatmap() – Heatmap

•     catplot() – Plot for categorical data with multiple types

3.    Plotly ( plotly.express & plotly.graph_objects)

•     line() – Line plot (Plotly Express)

•     scatter() – Scatter plot (Plotly Express)

•     bar() – Bar chart (Plotly Express)

•     histogram() – Histogram (Plotly Express)

•     box() – Box plot (Plotly Express)

•     pie() – Pie chart (Plotly Express)

•     px.sunburst():Sunburst chart is a hierarchical visualization that shows how

categories are organized into subcategories - like a tree, but drawn as concentric circles

•    Sankey Diagrams - flow diagram that emphasizes flow/movement/change from one state to another

Data analysis 3: Data modeling with Gurobi

•    Step 1: Create the model model = Model()

•    Step 2: define decision variables: x1 = model.addVar(vtype=, name=)

•    Step 3:  Objective function: maximize revenue: model.setObjective(expression, sense)

•    Step 4 Constraints: model.addConstr(expression, name="constraint_name")

•    Step 5: Solve the model while respecting all constraints: model.optimize()

•    Step 6: Check if a valid solution was found: model.status.

•    Step 7: Print the results

model.ObjVal → Returns the optimal value of the objective function

x.X → Returns the optimal value of each decision variable


联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!