1621406686

In this video we’ll talk a bit about big-o notation and analysis, how to understand time complexity, and how it’s related to understanding performance. We’ll approach this from the mathematical definition, going over the limiting behaviour and talking about the strict definition of big-o. How programmers tend to use Big-O informally, what they mean, and how that differs from the strict mathematical definition. There will be some easy examples to work through, talking about the dominant terms and how/why other terms are dropped. We’ll also talk about some of the more subtle aspects of big-o, when/why its good, where it kind of fails things, and cap it off with a story.

Github: https://github.com/simondevyoutube/

Subscribe: https://www.youtube.com/channel/UCEwhtpXrg5MmwlH04ANpL8A/featured

#big-o

1657081614

In this article, We will show how we can use python to automate Excel . A useful Python library is Openpyxl which we will learn to do Excel Automation

Openpyxl is a Python library that is used to read from an Excel file or write to an Excel file. Data scientists use Openpyxl for data analysis, data copying, data mining, drawing charts, styling sheets, adding formulas, and more.

**Workbook:** A spreadsheet is represented as a workbook in openpyxl. A workbook consists of one or more sheets.

**Sheet:** A sheet is a single page composed of cells for organizing data.

**Cell:** The intersection of a row and a column is called a cell. Usually represented by A1, B5, etc.

**Row:** A row is a horizontal line represented by a number (1,2, etc.).

**Column:** A column is a vertical line represented by a capital letter (A, B, etc.).

Openpyxl can be installed using the pip command and it is recommended to install it in a virtual environment.

`pip `

**install** openpyxl

We start by creating a new spreadsheet, which is called a workbook in Openpyxl. We import the workbook module from Openpyxl and use the

which creates a new workbook.**function** **Workbook**()

```
from openpyxl
import Workbook
#creates a new workbook
wb = Workbook()
#Gets the first active worksheet
ws = wb.active
#creating new worksheets by using the create_sheet method
ws1 = wb.create_sheet("sheet1", 0) #inserts at first position
ws2 = wb.create_sheet("sheet2") #inserts at last position
ws3 = wb.create_sheet("sheet3", -1) #inserts at penultimate position
#Renaming the sheet
ws.title = "Example"
#save the workbook
wb.save(filename = "example.xlsx")
```

We load the file using the

which takes the filename as an argument. The file must be saved in the same working directory.**function** **load_Workbook**()

```
#loading a workbook
wb = openpyxl.load_workbook("example.xlsx")
```

```
#getting sheet names
wb.sheetnames
result = ['sheet1', 'Sheet', 'sheet3', 'sheet2']
#getting a particular sheet
sheet1 = wb["sheet2"]
#getting sheet title
sheet1.title
result = 'sheet2'
#Getting the active sheet
sheetactive = wb.active
result = 'sheet1'
```

```
#get a cell from the sheet
sheet1["A1"] <
Cell 'Sheet1'.A1 >
#get the cell value
ws["A1"].value 'Segment'
#accessing cell using row and column and assigning a value
d = ws.cell(row = 4, column = 2, value = 10)
d.value
10
```

```
#looping through each row and column
for x in range(1, 5):
for y in range(1, 5):
print(x, y, ws.cell(row = x, column = y)
.value)
#getting the highest row number
ws.max_row
701
#getting the highest column number
ws.max_column
19
```

There are two functions for iterating through rows and columns.

```
Iter_rows() => returns the rows
Iter_cols() => returns the columns {
min_row = 4, max_row = 5, min_col = 2, max_col = 5
} => This can be used to set the boundaries
for any iteration.
```

**Example:**

```
#iterating rows
for row in ws.iter_rows(min_row = 2, max_col = 3, max_row = 3):
for cell in row:
print(cell) <
Cell 'Sheet1'.A2 >
<
Cell 'Sheet1'.B2 >
<
Cell 'Sheet1'.C2 >
<
Cell 'Sheet1'.A3 >
<
Cell 'Sheet1'.B3 >
<
Cell 'Sheet1'.C3 >
#iterating columns
for col in ws.iter_cols(min_row = 2, max_col = 3, max_row = 3):
for cell in col:
print(cell) <
Cell 'Sheet1'.A2 >
<
Cell 'Sheet1'.A3 >
<
Cell 'Sheet1'.B2 >
<
Cell 'Sheet1'.B3 >
<
Cell 'Sheet1'.C2 >
<
Cell 'Sheet1'.C3 >
```

To get all the rows of the worksheet we use the method worksheet.rows and to get all the columns of the worksheet we use the method worksheet.columns. Similarly, to iterate only through the values we use the method worksheet.values.

**Example:**

```
for row in ws.values:
for value in row:
print(value)
```

Writing to a workbook can be done in many ways such as adding a formula, adding charts, images, updating cell values, inserting rows and columns, etc… We will discuss each of these with an example.

```
#creates a new workbook
wb = openpyxl.Workbook()
#saving the workbook
wb.save("new.xlsx")
```

```
#creating a new sheet
ws1 = wb.create_sheet(title = "sheet 2")
#creating a new sheet at index 0
ws2 = wb.create_sheet(index = 0, title = "sheet 0")
#checking the sheet names
wb.sheetnames['sheet 0', 'Sheet', 'sheet 2']
#deleting a sheet
del wb['sheet 0']
#checking sheetnames
wb.sheetnames['Sheet', 'sheet 2']
```

```
#checking the sheet value
ws['B2'].value
null
#adding value to cell
ws['B2'] = 367
#checking value
ws['B2'].value
367
```

We often require formulas to be included in our Excel datasheet. We can easily add formulas using the Openpyxl module just like you add values to a cell.

**For example:**

```
import openpyxl
from openpyxl
import Workbook
wb = openpyxl.load_workbook("new1.xlsx")
ws = wb['Sheet']
ws['A9'] = '=SUM(A2:A8)'
wb.save("new2.xlsx")
```

The above program will add the formula (=SUM(A2:A8)) in cell A9. The result will be as below.

Two or more cells can be merged to a rectangular area using the method merge_cells(), and similarly, they can be unmerged using the method unmerge_cells().

**For example:****Merge cells**

```
#merge cells B2 to C9
ws.merge_cells('B2:C9')
ws['B2'] = "Merged cells"
```

Adding the above code to the previous example will merge cells as below.

```
#unmerge cells B2 to C9
ws.unmerge_cells('B2:C9')
```

The above code will unmerge cells from B2 to C9.

To insert an image we import the image function from the module openpyxl.drawing.image. We then load our image and add it to the cell as shown in the below example.

**Example:**

```
import openpyxl
from openpyxl
import Workbook
from openpyxl.drawing.image
import Image
wb = openpyxl.load_workbook("new1.xlsx")
ws = wb['Sheet']
#loading the image(should be in same folder)
img = Image('logo.png')
ws['A1'] = "Adding image"
#adjusting size
img.height = 130
img.width = 200
#adding img to cell A3
ws.add_image(img, 'A3')
wb.save("new2.xlsx")
```

**Result:**

Charts are essential to show a visualization of data. We can create charts from Excel data using the Openpyxl module chart. Different forms of charts such as line charts, bar charts, 3D line charts, etc., can be created. We need to create a reference that contains the data to be used for the chart, which is nothing but a selection of cells (rows and columns). I am using sample data to create a 3D bar chart in the below example:

**Example**

```
import openpyxl
from openpyxl
import Workbook
from openpyxl.chart
import BarChart3D, Reference, series
wb = openpyxl.load_workbook("example.xlsx")
ws = wb.active
values = Reference(ws, min_col = 3, min_row = 2, max_col = 3, max_row = 40)
chart = BarChart3D()
chart.add_data(values)
ws.add_chart(chart, "E3")
wb.save("MyChart.xlsx")
```

**Result**

Welcome to another video! In this video, We will cover how we can use python to automate Excel. I'll be going over everything from creating workbooks to accessing individual cells and stylizing cells. There is a ton of things that you can do with Excel but I'll just be covering the core/base things in OpenPyXl.

⭐️ Timestamps ⭐️

00:00 | Introduction

02:14 | Installing openpyxl

03:19 | Testing Installation

04:25 | Loading an Existing Workbook

06:46 | Accessing Worksheets

07:37 | Accessing Cell Values

08:58 | Saving Workbooks

09:52 | Creating, Listing and Changing Sheets

11:50 | Creating a New Workbook

12:39 | Adding/Appending Rows

14:26 | Accessing Multiple Cells

20:46 | Merging Cells

22:27 | Inserting and Deleting Rows

23:35 | Inserting and Deleting Columns

24:48 | Copying and Moving Cells

26:06 | Practical Example, Formulas & Cell Styling

📄 Resources 📄

OpenPyXL Docs: https://openpyxl.readthedocs.io/en/stable/

Code Written in This Tutorial: https://github.com/techwithtim/ExcelPythonTutorial

Subscribe: https://www.youtube.com/c/TechWithTim/featured

1598383290

The Google computer engine exchanges a large number of scalable virtual machines to serve as clusters used for that purpose. GCE can be managed through a RESTful API, command line interface, or web console. The computing engine is serviced for a minimum of 10-minutes per use. There is no up or front fee or time commitment. GCE competes with Amazon’s Elastic Compute Cloud (EC2) and Microsoft Azure.

https://www.mrdeluofficial.com/2020/08/what-are-google-compute-engine-explained.html

#google compute engine #google compute engine tutorial #google app engine #google cloud console #google cloud storage #google compute engine documentation

1625640780

Hey guys, In this video, we’ll be talking about Time complexity and Big O notation. This is the first video of our DSA-One Course. We’ll also learn how to find the time complexity of Recursive problems.

Practice here: https://www.interviewbit.com/courses/programming/topics/time-complexity/

Follow for updates:

Instagram: https://www.instagram.com/Anuj.Kumar.Sharma

LinkedIn: https://www.linkedin.com/in/anuj-kumar-sharma-294533138/

Telegram: https://t.me/coding_enthusiasts

Ignore these tags:

time complexity,time complexity of algorithms,time complexity analysis,complexity,time complexity tutorial,time and space complexity,time complexity explained,examples of time complexity,time,space complexity,time complexity in hindi,time complexity examples,analysis of time complexity,time complexity calculation,how to calculate time complexity,time and space complexity in hindi,time complexity of algorithms in hindi,what is time complexity in data structure,all time complexity

#big o #big o notation #time complexity

1593442500

Big O notation is a commonly used metric used in computer science to classify algorithms based on their time and space complexity. The time and space here is not based on the actual number of operations performed or amount of memory used per se, but rather how the algorithm would scale with an increase or decrease in the amount of data in the input. The notation will represent how an algorithm will run in the worst-case scenario- what is the maximum time or space an algorithm could use? The complexity is written as O(x) where x is the growth rate of the algorithm in regards to n, which is the amount of data input. Throughout the rest of this blog, input will be referred to as n.

O(1) is known as **constant complexity**. What this implies is that the amount of time or memory does not scale with n at all. For time complexity, this means that n is not iterated on or recursed- generally a value will be selected and returned or a value with be operated on and returned.

Function that returns an index of an array doubled in O(1) time complexity.

For space, no data structures can be created that are a multiples of the size of n. Variables can be declared, but the number must not change with n.

Function that logs every element in an array with O(1) space.

O(logn) is known as **logarithmic complexity**. The logarithm in O(logn) has a base of 2. The best way to wrap your head around this is to remember the concept of halving: every time n increases by an amount k, the time or space increases by k/2. There are several common algorithms that are O(logn) a vast majority of the time to keep an eye out for: binary search, searching for a term in a binary search tree, and adding items to a heap.

#algorithms #computer-science #big-o-notation #time-complexity #space-complexity #algorithms

1621406686

In this video we’ll talk a bit about big-o notation and analysis, how to understand time complexity, and how it’s related to understanding performance. We’ll approach this from the mathematical definition, going over the limiting behaviour and talking about the strict definition of big-o. How programmers tend to use Big-O informally, what they mean, and how that differs from the strict mathematical definition. There will be some easy examples to work through, talking about the dominant terms and how/why other terms are dropped. We’ll also talk about some of the more subtle aspects of big-o, when/why its good, where it kind of fails things, and cap it off with a story.

Github: https://github.com/simondevyoutube/

Subscribe: https://www.youtube.com/channel/UCEwhtpXrg5MmwlH04ANpL8A/featured

#big-o