0% found this document useful (0 votes)
22 views242 pages

PYTHON

Uploaded by

om9971564935
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views242 pages

PYTHON

Uploaded by

om9971564935
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 242

Python is an object-oriented programming language, which means it deals with False

objects. Everything in Python is an object, including numbers, strings, lists, and <class 'bool'>
even functions. Objects have attributes and methods associated with them. Set:

Numbers: A set is an unordered collection of unique elements. Sets are mutable, meaning
they can be modified after creation, but they cannot contain duplicate elements.
Python supports various types of numbers, including integers, floating-point
numbers, and complex numbers.
In [ ]: my_set = {1, 2, 3, 4, 5}
print(my_set)
• Integer: print(type(my_set))

Represents integers (whole numbers). {1, 2, 3, 4, 5}


<class 'set'>

In [ ]: num_int = 42 In [ ]: my_dict = {'name': 'John', 'age': 25, 'city': 'New York'}


print(num_int) print(my_dict)
print(type(num_int)) print(type(my_dict))
42 {'name': 'John', 'age': 25, 'city': 'New York'}
<class 'int'> <class 'dict'>

Sequence:
• Float
Strings in Python are sequences of characters enclosed in single, double, or triple
In [ ]: num_int_error = 3.14 quotes. They support various operations such as concatenation, slicing, and
print(num_int_error)
print(type(num_int_error)) formatting.

3.14
In [ ]: my_str = "Hello, World!"
<class 'float'>
print(my_str)
print(type(my_str))
• Complex
Hello, World!
<class 'str'>
In [ ]: num_complex = 2 + 3j
print(num_complex) # List:
print(type(num_complex))
A list is a versatile data structure used to store collections of items. Lists are
(2+3j)
mutable, meaning they can be modified after creation. Each item in a list is
<class 'complex'>
indexed, and you can access elements by their index. Lists can contain items of
Bool: Booleans represent truth values, either True or False .
different data types, and they can also contain other lists (nested lists).

In [ ]: bool_true = True
In [ ]: my_list = [1, 2, 3, 4, 5]
print(bool_true)
print(my_list)
print(type(bool_true))
print(type(my_list))
True
[1, 2, 3, 4, 5]
<class 'bool'>
<class 'list'>
In [ ]: bool_false = False Tuple:
print(bool_false)
print(type(bool_false))
A tuple in Python is a collection of ordered and immutable elements. It is similar to
a list, but unlike lists, tuples are immutable, meaning their elements cannot be In [1]: a = 3
changed after creation. Tuples are defined using parentheses () and can contain
elements of different data types. In [2]: a

Out[2]: 3
In [ ]: my_tuple = (1, 'two', 3.0)
print(my_tuple)
print(type(my_tuple)) In [4]: b = "Ajay"

(1, 'two', 3.0) In [5]: b


<class 'tuple'>
Out[5]: 'Ajay'
None:

None is a special constant representing the absence of a value or a null value. It is In [6]: b[2]

often used to indicate that a variable or an object does not have a meaningful Out[6]: 'a'
value or has not been assigned yet.
In [7]: b[-2]
In [ ]: my_none = None
print(my_none) Out[7]: 'a'
print(type(my_none))
In [8]: #anaother type of data container
None
list_cont = [1, 2, 3, "Ajay", 3+5j, True, "a"]
<class 'NoneType'>

In [9]: type(list_cont)

Out[9]: list

In [10]: list_cont[3]

Out[10]: 'Ajay'

In [11]: list_cont[3] = "Bijay"

In [12]: list_cont

Out[12]: [1, 2, 3, 'Bijay', (3+5j), True, 'a']

In [13]: #objects/container whose state or value can be changed after they are created are call

In [16]: b = "pwskills"

In [17]: b[2]

Out[17]: 's'

In [18]: b[2] = "I"


--------------------------------------------------------------------------- In [1]: #what is operator>>> special keywords to perform operations
TypeError Traceback (most recent call last) #why? To manipualte data
Cell In[18], line 1
----> 1 b[2] = "I"
#arithmatic operator
TypeError: 'str' object does not support item assignment a = 5
b = 2
a+b
In [ ]: #objects/container whose state or value can not be changed after they are created are called immutable objects

Out[1]: 7

In [5]: add = 5+2


print(add)

In [3]: add

Out[3]: 7

In [4]: 5+2

Out[4]: 7

In [6]: 20 - 3

Out[6]: 17

In [7]: 3 * 4

Out[7]: 12

In [8]: 20 / 4

Out[8]: 5.0

In [9]: #modulus operator


17 % 4

Out[9]: 1

In [10]: 2 ** 3 #2*2*2

Out[10]: 8

In [11]: 3 ** 2

Out[11]: 9

In [13]: 4/ 3
Out[13]: 1.3333333333333333 In [24]: #Logical operator
#and
True and True
In [14]: 4 // 3 #floor operator
Out[24]: True
Out[14]: 1

In [26]: True and False


In [ ]: a = 2
Out[26]: False
In [12]: # Comparison operator >> compare two values>> return a boolean value
In [27]: False and True
2 == 2
Out[27]: False
Out[12]: True

In [28]: False and False


In [15]: 2 != 2
Out[28]: False
Out[15]: False

In [29]: True or False


In [16]: 5 != 2
Out[29]: True
Out[16]: True

In [30]: False or True


In [17]: 10>2
Out[30]: True
Out[17]: True

In [31]: #Not operator


In [18]: 10 < 5
not True

Out[18]: False
Out[31]: False

In [19]: 10 >= 10
In [32]: not False

Out[19]: True
Out[32]: True

In [20]: 10 >= 1
In [33]: #Assignment operator

Out[20]: True
a =10

In [21]: 10<=10
In [34]: a

Out[21]: True
Out[34]: 10

In [22]: 10 <= 12
In [35]: a + 5

Out[22]: True
Out[35]: 15

In [23]: 10 >= 12
In [36]: a

Out[23]: False
Out[36]: 10
In [38]: a = a + 10 Out[52]: True

In [39]: a In [53]: a = ["data", "science", "ajay"]

Out[39]: 20
In [56]: "data" in a

In [40]: a += 5 Out[56]: True

In [41]: a In [58]: #identity operator >> compare the memory location of two object
a = 2
Out[41]: 25

In [59]: b = 3
In [42]: a

In [60]: a is b
Out[42]: 25

Out[60]: False
In [44]: a *= 2

In [61]: b is a
In [45]: a
Out[61]: False
Out[45]: 50

In [62]: a = "Pw Skills"


In [46]: a b=a

Out[46]: 50
In [63]: b is a

In [47]: a /= 3 Out[63]: True

In [48]: a In [64]: a is b

Out[48]: 16.666666666666668 Out[64]: True

In [49]: #membership operator In [65]: a = "pwskills"


b = "data"
a = "PWSKILLS" a is b

"P" in a Out[65]: False

Out[49]: True
In [66]: a is not b

In [50]: "am" in "I am Ajay" Out[66]: True

Out[50]: True
In [129… #bitwise operator>> operations at bit level
10 & 10
In [51]: "data" in "PWSKILLS"
Out[129… 10
Out[51]: False

In [130… 18 & 3
In [52]: "data" not in "PWSKILLS"
Out[130… 2 Out[144… '0b101'

In [131… bin(10) In [145… bin(3)

Out[131… '0b1010' Out[145… '0b11'

In [132… bin(18) In [146… bin(6)

Out[132… '0b10010' Out[146… '0b110'

In [133… bin(3) In [ ]: #shift >> left shift and right shift

Out[133… '0b11' In [147… #left shift put no of zeros on right side

In [134… bin(2) 35 << 3

Out[134… '0b10' Out[147… 280

In [135… 3 | 5 In [148… bin(35)

Out[135… 7 Out[148… '0b100011'

In [136… bin(3) In [149… bin(280)

Out[136… '0b11' Out[149… '0b100011000'

In [137… bin(5) In [150… 5 << 1

Out[137… '0b101' Out[150… 10

In [138… #negation In [151… bin(5)


~3
Out[151… '0b101'
Out[138… -4
In [152… bin(10)
In [141… ~100
Out[152… '0b1010'
Out[141… -101
In [154… #Right shift operator >> remove the no of elements in the binary
In [142… ~6 280 >> 3

Out[142… -7 Out[154… 35

In [143… #Bitwise xor >> return 1 when exactly one operand is 1 In [155… bin(280)

5 ^ 3 Out[155… '0b100011000'

Out[143… 6 In [156… bin(35)

In [144… bin(5) Out[156… '0b100011'


In [157… 10 >> 1
1. Converting to Integer (int())
Out[157… 5
In [ ]: # Convert a float to an integer
In [158… bin(10) float_num = 10.5
int_num = int(float_num)
Out[158… '0b1010' print(int_num)

10
In [159… bin(5)
In [ ]: type(int_num)
Out[159… '0b101'
Out[ ]: int
In [160… ## order of precedence
#execution will start from left
In [ ]: # Convert a string to an integer
2+3-1
str_num = "42"
int_str = int(str_num)
Out[160… 4
print(int_str)

In [161… #always parenthesis 42

(5+3) - 4 In [ ]: type(int_num)

Out[161… 4 Out[ ]: int

In [162… 4 - (5+3)
2. Converting to Float (float())
Out[162… -4
In [ ]: # Convert an integer to a float
In [163… (10+5) + (8/2) int_num = 34
float_num = float(int_num)
Out[163… 19.0 print(float_num)

34.0
In [ ]:
In [ ]: type(float_num)

Out[ ]: float

In [ ]: # Convert a string to a float


str_num = "2.12"
float_str = float(str_num)
print(float_str)

2.12

In [ ]: type(float_num)

Out[ ]: float
In [1]: #Type conversion >> The process of changing the data type of a value or object in Pyth
3. Converting to String (str()) a = "5"
type(a)
In [ ]: # Convert an integer to a string
Out[1]: str
int_num = 32
str_num = str(int_num)
print(str_num) In [2]: a+2

32 ---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
In [ ]: type(str_num) Cell In[2], line 1
----> 1 a+2
Out[ ]: str
TypeError: can only concatenate str (not "int") to str
In [ ]: # Convert a float to a string
float_num = 2.89 In [3]: type(2)
str_num = str(float_num)
print(str_num) Out[3]: int

2.89
In [4]: type(a)
In [ ]: type(str_num)
Out[4]: str
Out[ ]: str
In [ ]: #TYPE CASTING >> implicit and explicit

4. Converting to Boolean (bool()) In [5]: x = 2

In [ ]: # Convert an integer to a boolean In [6]: type(2)


int_num = 0
bool_num = bool(int_num) Out[6]: int
print(bool_num)
In [7]: 2+3.5
False
Out[7]: 5.5
In [ ]: # Convert a non-empty string to a boolean
non_empty_str = "PWskills"
bool_str = bool(non_empty_str) In [8]: a = "5"
print(bool_str)
In [9]: a
True
Out[9]: '5'
In [ ]: # Convert an empty string to a boolean
empty_str = ""
bool_empty_str = bool(empty_str) In [10]: type(a)
print(bool_empty_str)
Out[10]: str
False
In [11]: "ram" + "shyam"
In [ ]:
Out[11]: 'ramshyam'

In [12]: type(a)
Out[12]: str In [ ]:

In [13]: a+"shyam"

Out[13]: '5shyam'

In [14]: #explicit type conversion >> convert data type using inbuilt function

#string
#int
#float
#bool

In [15]: x = 22.5
y = int(22.5)

In [16]: type(y)

Out[16]: int

In [17]: y

Out[17]: 22

In [19]: s = "33"
a = int(s)

In [20]: type(a)

Out[20]: int

In [21]: b = "33.5"
c = float(b)

In [22]: c

Out[22]: 33.5

In [23]: type(c)

Out[23]: float

In [24]: bool(0)

Out[24]: False

In [25]: bool(1)

Out[25]: True
'if' Statement 'if-elif-else' Statement
In [ ]: course = "DataScience" In [ ]: course = "DataScience"
if course == "DataScience": if course == "DataScience":
print("You are on the right track!") print("You are in PWskills's course.")
elif course == "Physics":
You are on the right track! print("You are in Physics Wallah's course.")
else:
In [ ]: PWskills_grades = 8
print("You are not enrolled in any course.")
if PWskills_grades >= 7:
print("Impressive PWskills!") You are in PWskills's course.

Impressive PWskills! In [ ]: grades = 5

In [ ]: marks = 90
if grades >= 7:
if marks >= 90:
print("Impressive skills!")
print("You got an 'A' grade!")
elif grades >= 5:
You got an 'A' grade! print("You're doing well at Physics Wallah!")
else:
In [ ]: number = 42 print("Keep working on your skills.")
if number % 2 == 0:
You're doing well at Physics Wallah!
print("The number is even.")

The number is even. In [ ]: marks = 75


if marks >= 90:
In [ ]: temperature = 25 print("You got an 'A' grade!")
if temperature > 20: elif marks >= 80:
print("It's a warm day.") print("You got a 'B' grade.")
else:
It's a warm day. print("You got a grade lower than 'B'.")

In [ ]: age = 18 You got a grade lower than 'B'.


if age >= 18:
print("You are an adult.") In [ ]: grade = "A"
else: if grade == "A":
print("You are not an adult.") print("Excellent!")
elif grade == "B":
You are an adult. print("Good job.")
else:
In [ ]: score = 75 print("Try harder.")
passing_score = 70
if score >= passing_score: Excellent!
print("Congratulations, you passed!")
else: In [ ]: num = 0
if score >= passing_score - 5: if num > 0:
print("You almost passed.") print("Positive")
else: elif num < 0:
print("You didn't pass.") print("Negative")
else:
Congratulations, you passed! print("Zero")

Zero

In [ ]: age = 30
if age < 18:
print("You are a minor.") Nested 'if-else' Statement
elif 18 <= age < 65:
print("You are an adult.")
In [ ]: course = "DataScience"
else:
print("You are a senior citizen.")
grades = 7
You are an adult. if course == "DataScience":
if grades >= 7:
print("Impressive skills in Data Science at PWskills!")
'if-else' Statement Impressive skills in Data Science at PWskills!

In [ ]: In [ ]: marks = 88
if marks >= 80:
In [ ]: course = "DataScience" if marks >= 90:
print("You got an 'A' grade!")
if course == "DataScience": else:
print("You are studying Data Science.") print("You got a 'B' grade.")
else: You got a 'B' grade.
print("You are not in the Data Science course.")

You are studying Data Science. In [ ]: is_weekend = False


is_sunny = True
In [ ]: PWskills_grades = 8
if is_weekend:
if PWskills_grades >= 7: if is_sunny:
print("Impressive PWskills!") print("Go for a picnic.")
else: else:
print("You're making progress at Physics Wallah!") print("Stay in and relax.")
else:
Impressive PWskills! print("It's a workday.")

In [ ]: is_raining = True It's a workday.


if is_raining:
print("Take an umbrella.") In [ ]: is_student = True
else: is_teacher = False
print("Enjoy the sunshine.")
if is_student:
Take an umbrella. if is_teacher:
print("You are both a student and a teacher.")
In [ ]: num = 7 else:
if num % 2 == 0: print("You are a student but not a teacher.")
print("Even") else:
else: if is_teacher:
print("Odd") print("You are a teacher but not a student.")
else:
Odd
print("You are neither a student nor a teacher.")
In [ ]: score = 85 You are a student but not a teacher.
result = "Pass" if score >= 70 else "Fail"
print(f"You {result}.") In [ ]: is_vip = True
age = 30
You Pass.
if is_vip:
if age >= 18:
if age < 65:
print("Welcome, VIP customer!") 1. 'for' loop
else:
print("You're a VIP, but you qualify for senior discounts.")
In [ ]: # Printing a list of courses
else:
print("VIP status is for adults only.")
courses = ["DataScience", "DataAnalytics", "Python", "JavaScript"]
else:
print("Regular pricing applies.")
for course in courses:
Welcome, VIP customer! print(course)

DataScience
In [ ]:
DataAnalytics
Python
JavaScript

In [ ]: # Iterating through a List

fruits = ["apple", "banana", "cherry"]

for fruit in fruits:


print("I like", fruit)

I like apple
I like banana
I like cherry

In [ ]: # Generating a Number Sequence


for i in range(1, 6):
print("Number:", i)

Number: 1
Number: 2
Number: 3
Number: 4
Number: 5

In [ ]: # Counting and displaying course names

courses = ["DataScience", "DataAnalytics", "Python", "JavaScript"]


count = 1

for course in courses:


print(f"Course {count}: {course}")
count += 1

Course 1: DataScience
Course 2: DataAnalytics
Course 3: Python
Course 4: JavaScript

In [ ]: # Finding and printing the length of each course name

courses = ["DataScience", "DataAnalytics", "Python", "JavaScript"]

for course in courses:


length = len(course) 1 * 1 = 1
print(f"The course name '{course}' has {length} characters.") 1 * 2 = 2
1 * 3 = 3
The course name 'DataScience' has 11 characters. 1 * 4 = 4
The course name 'DataAnalytics' has 13 characters. 1 * 5 = 5
The course name 'Python' has 6 characters. 1 * 6 = 6
The course name 'JavaScript' has 10 characters. 1 * 7 = 7
1 * 8 = 8

2. Nested 'for' loop 1


1
*
*
9 = 9
10 = 10

In [ ]: # Multiplication table 2 * 1 = 2
2 * 2 = 4
for i in range(1, 6): 2 * 3 = 6
for j in range(1, 11): 2 * 4 = 8
product = i * j 2 * 5 = 10
print(f"{i} * {j} = {product}") 2 * 6 = 12
print() 2 * 7 = 14
2 * 8 = 16
2 * 9 = 18
2 * 10 = 20

3 * 1 = 3
3 * 2 = 6
3 * 3 = 9
3 * 4 = 12
3 * 5 = 15
3 * 6 = 18
3 * 7 = 21
3 * 8 = 24
3 * 9 = 27
3 * 10 = 30

4 * 1 = 4
4 * 2 = 8
4 * 3 = 12
4 * 4 = 16
4 * 5 = 20
4 * 6 = 24
4 * 7 = 28
4 * 8 = 32
4 * 9 = 36
4 * 10 = 40

5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50
'while' loop
In [ ]: # Printing a Pattern
for i in range(5):
In [ ]: #Printing course names until a condition is met
for j in range(i + 1):
print("*", end=" ")
courses = ["DataScience", "DataAnalytics", "Python", "JavaScript"]
print()
index = 0
*
* * while index < len(courses):
* * * print(courses[index])
* * * * index += 1
* * * * *
DataScience
DataAnalytics
In [ ]: # Creating a Matrix
Python
JavaScript
rows = 3
cols = 3
In [ ]: #Counting the number of characters in course names
matrix = []

courses = ["DataScience", "DataAnalytics", "Python", "JavaScript"]


for i in range(rows):
index = 0
row = []
for j in range(cols):
while index < len(courses):
row.append(i * cols + j)
course = courses[index]
matrix.append(row)
length = len(course)
print(f"The course '{course}' has {length} characters.")
for row in matrix:
index += 1
print(row)
The course 'DataScience' has 11 characters.
[0, 1, 2]
The course 'DataAnalytics' has 13 characters.
[3, 4, 5]
The course 'PWskills' has 8 characters.
[6, 7, 8]
The course 'PhysicsWallah' has 13 characters.
In [ ]: # Matrix multiplication
In [ ]: # Counting Down
matrix_A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
count = 5
matrix_B = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]
result = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
while count > 0:
print(count)
for i in range(len(matrix_A)):
count -= 1
for j in range(len(matrix_B[0])):
for k in range(len(matrix_B)): 5
result[i][j] += matrix_A[i][k] * matrix_B[k][j] 4
3
for row in result: 2
print(row) 1
[30, 24, 18]
In [ ]: # Right Triangle
[84, 69, 54]
[138, 114, 90]
row = 1
while row <= 4:
col = 1
while col <= row:
print("*", end=" ")
col += 1
print() 1. 'break' Statement
row += 1

* In [ ]: # Exiting a Loop Based on a Condition


* *
* * * grades = [12, 34 ,56, 65, 67, 56, 43, 54, 43,89]
* * * *
for grade in grades :
In [ ]: # Square if grade == 56:
side = 1 print("Found the number 56. Exiting the loop.")
while side <= 3: break
width = 1 print("Current grade :", grade)
while width <= 3:
Found the number 56. Exiting the loop.
print("*", end=" ")
Current grade : 56
width += 1
print()
In [ ]: # Searching for an Element in a List
side += 1

* * * courses = ["Blockchain", "DataAnalytics", "Java", "C++", "DataScience"]


* * *
* * * search_course = "DataScience"

In [ ]: for course in courses:


if course == search_course:
print(f"{search_course} is found in the list.")
break
else:
print(f"{search_course} is not in the list.")

DataScience is found in the list.

In [ ]: PWskills = ["Python", "Data Science", "Java", "Data Analytics"]


for skill in PWskills:
if skill == "Data Science":
break
print("Learn:", skill)

Learn: Python

In [ ]: PWskills = ["Python", "Data Science", "Java", "Data Analytics"]


for skill in PWskills:
if skill == "Java":
break
print("Learn:", skill)

Learn: Python
Learn: Data Science

In [ ]: PWskills = ["Python", "Data Science", "Java", "Data Analytics"]


for skill in PWskills:
if skill == "Data Science":
print("This is the best course.")
break
print("Learn:", skill)
Learn: Python Python Skill: Python for DataScience
This is the best course. Python Skill: Python for Web

'continue' Statement range() function


In [ ]: # Skipping Even Numbers In [ ]: # Generating a Sequence of Numbers

for i in range(10): for num in range(5):


if i % 2 == 0: print(num)
continue
print(i) 0
1
1 2
3 3
5 4
7
9 In [ ]: # Custom Range with a Specified Start and Step

In [ ]: # Skipping Specific Values in a List for num in range(2, 10, 2):


print(num)
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
2
for number in numbers: 4
if number == 3 or number == 7: 6
continue 8
print(number)
In [ ]: #Summing Even Numbers in a Range
1
2 start = 4
4 end = 50
5
6 # Initialize a variable to store the sum
8 even_sum = 0
9
10 for num in range(start, end + 1):
if num % 2 == 0: # Check if the number is even
In [ ]: #Skipping Java and Continuing to Learn Skills even_sum += num
PWskills = ["Python", "Data Science", "Java", "Data Analytics"]
for skill in PWskills: print(f"The sum of even numbers from {start} to {end} is {even_sum}")
if "Java" in skill:
continue The sum of even numbers from 4 to 50 is 648
print("Learn:", skill)
In [ ]:
Learn: Python
Learn: Data Science
Learn: Data Analytics

In [ ]: PWskills = ["Python for DataScience","Python for Web", "Data Science", "Java",


for skill in PWskills:
if "Python" not in skill:
continue
print("Python Skill:", skill)
In [1]: #data structure > way of organizing and storing data so that it can be acccessed and manipulated
In effecinently
[15]: lis

In [2]: #List >> it is an ordered collection of elements that can be of any data type, integer, float Out[15]: [1, 2, True, (3+7j), 'pwskills']
#List are mutable
In [16]: lis[2]
In [3]: num = [1, 2, 3, 4, 5]
Out[16]: True

In [4]: type(num)
In [17]: lis = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
Out[4]: list
In [18]: type(lis)
In [5]: num[0]
Out[18]: list
Out[5]: 1
In [19]: lis
In [6]: num[1]
Out[19]: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
Out[6]: 2
In [21]: lis[0][1]
In [7]: num[4]
Out[21]: 2
Out[7]: 5
In [23]: lis[2][2]
In [8]: num[5]
Out[23]: 9
---------------------------------------------------------------------------
IndexError Traceback (most recent call last) In [24]: shopping_list = ["Banana", "Apple", 3, 4.5, True]
Cell In[8], line 1
----> 1 num[5] In [25]: type(shopping_list)

IndexError: list index out of range Out[25]: list

In [9]: lis = [1, 2, "ajay", True, 3+7j]


In [27]: for item in shopping_list:
print(item, end = " ")
In [10]: type(lis)
Banana Apple 3 4.5 True
Out[10]: list
In [28]: #Tuples >> immutable
In [11]: lis
In [29]: point = (2, 3)
Out[11]: [1, 2, 'ajay', True, (3+7j)]
In [30]: point
In [12]: lis.append("pwskills")
Out[30]: (2, 3)
In [13]: lis
In [31]: type(point)
Out[13]: [1, 2, 'ajay', True, (3+7j), 'pwskills']
Out[31]: tuple
In [14]: lis.remove("ajay")
In [33]: point = ("Ajay", 1, 2, 2.3)
In [34]: point In [49]: s

Out[34]: ('Ajay', 1, 2, 2.3) Out[49]: {'blue', 'red'}

In [35]: name = ("Ajay", "Sumit", "Bijay") In [51]: s = {"a", "a", "a", 1.2, 1.2}

In [36]: name[0] In [52]: s

Out[36]: 'Ajay' Out[52]: {1.2, 'a'}

In [37]: name[1] In [53]: s

Out[37]: 'Sumit' Out[53]: {1.2, 'a'}

In [38]: name[1] = "Bangalore" In [54]: s[0]

--------------------------------------------------------------------------- ---------------------------------------------------------------------------
TypeError Traceback (most recent call last) TypeError Traceback (most recent call last)
Cell In[38], line 1 Cell In[54], line 1
----> 1 name[1] = "Bangalore" ----> 1 s[0]

TypeError: 'tuple' object does not support item assignment TypeError: 'set' object is not subscriptable

In [42]: box1 = ("a", "b") In [55]: s[1]


box2 = ("c", "d")
---------------------------------------------------------------------------
choclate_bag = (box1, box2) TypeError Traceback (most recent call last)
Cell In[55], line 1
In [43]: choclate_bag ----> 1 s[1]

Out[43]: (('a', 'b'), ('c', 'd')) TypeError: 'set' object is not subscriptable

In [57]: s.add("pwskills")
In [44]: for bag in choclate_bag:
for choc in bag:
In [58]: s
print(choc)

a Out[58]: {1.2, 'a', 'pwskills'}


b
c In [59]: s.add("pwskills")
d
In [60]: s
In [45]: #sets>> are unordered collection of unique elements

Out[60]: {1.2, 'a', 'pwskills'}


In [46]: s = {"red", "blue"}

In [61]: s
In [47]: type(s)
Out[61]: {1.2, 'a', 'pwskills'}
Out[47]: set

In [62]: s.remove("pwskills")
In [48]: s = {"red", "blue", "blue"}

In [63]: s
Out[63]: {1.2, 'a'} In [81]: phonebook.values()

Out[81]: dict_values([789, 234])


In [64]: grocery_list = {"apple", "banana", "orange", "banana", "orange"}
grocery_list
In [82]: phonebook["Dad"] = "I have changed any no"
Out[64]: {'apple', 'banana', 'orange'}
In [83]: phonebook
In [65]: #dictionaries >> key value pair
my_dict = {} Out[83]: {'Dad': 'I have changed any no', 'Mom': 234}

In [66]: my_dict In [85]: from array import array # array is similar to list>> homogenous data

Out[66]: {} In [86]: array('i', [1, 2, 3, 4])

In [70]: type(my_dict) Out[86]: array('i', [1, 2, 3, 4])

Out[70]: dict In [ ]:

In [71]: s = {}
type(s)

Out[71]: dict

In [72]: my_dict = {"key_course" : "data science", "duration" : 2}

In [73]: type(my_dict)

Out[73]: dict

In [74]: phonebook = {"Dad": 1234, "Mom": 234}

In [75]: type(phonebook)

Out[75]: dict

In [76]: phonebook["Dad"]

Out[76]: 1234

In [77]: phonebook = {"Dad": 1234, "Mom": 234, "Dad": 789}

In [78]: phonebook

Out[78]: {'Dad': 789, 'Mom': 234}

In [80]: phonebook.keys()

Out[80]: dict_keys(['Dad', 'Mom'])


In [1]: #string is a sequence of character In [19]: 'pwskills'
#characterd represented using numerical values
#ASCII (7 bits) and UNICODE (16 bits) Out[19]: 'pwskills'
#UTF-8, UTF 16 >> popular encoding schemes
In [21]: "I'm a good student"
In [2]: #ASCII representation
char = "A" Out[21]: "I'm a good student"
ord(char)
In [23]: """I"m a good student"""
Out[2]: 65
Out[23]: 'I"m a good student'
In [3]: ord("B")
In [24]: '''I"m a good student'''
Out[3]: 66
Out[24]: 'I"m a good student'
In [4]: ord("a")
In [25]: '''I"m a good student.
Out[4]: 97 I study at pwskills
I am data scientist'''
In [6]: chr(101)
Out[25]: 'I"m a good student.\nI study at pwskills\nI am data scientist'
Out[6]: 'e'
In [27]: #concatenation of string ?? combining of two strings
In [7]: chr(66) string1 = "hello"
string2 = "world"
Out[7]: 'B'
string1 +", " +string2
In [8]: #UNICODE representation #omega
'\u03A9' Out[27]: 'hello, world'

Out[8]: 'Ω' In [28]: "String" + ">" +"concatenation"

In [9]: '\u03A3' Out[28]: 'String>concatenation'

Out[9]: 'Σ' In [29]: "String" + " > " +"concatenation"

In [11]: '\u0973' Out[29]: 'String > concatenation'

Out[11]: '⯑' In [30]: #Extract a string


string1 = "I am a good student"
In [15]: chr(975)
In [33]: string1[0:4]
Out[15]: 'Ϗ'
Out[33]: 'I am'
In [16]: string1 = 'pwskills'
In [35]: string1[5:12]
In [17]: type(string1)
Out[35]: 'a good '
Out[17]: str
In [36]: string2 = "pwskills"
string2[1:] In [55]: #strings are immutable
s
Out[36]: 'wskills'
Out[55]: 'pwskills'
In [37]: string2[-1]
In [57]: s[1] = "x"
Out[37]: 's'
---------------------------------------------------------------------------
In [38]: string2[-4] TypeError Traceback (most recent call last)
Cell In[57], line 1
Out[38]: 'i' ----> 1 s[1] = "x"

TypeError: 'str' object does not support item assignment


In [41]: string2[:-3] #except last three characters
In [58]: "PW" + "SKILLS"
Out[41]: 'pwski'
Out[58]: 'PWSKILLS'
In [42]: string2[-3:] #last 3 charcters
In [59]: s
Out[42]: 'lls'
Out[59]: 'pwskills'
In [43]: string2 = "hello world"
In [60]: len(s)
In [44]: string2[::1] #step size is by default 1
Out[60]: 8
Out[44]: 'hello world'
In [61]: s = "I am a student"
In [45]: string2[0:] len(s)

Out[45]: 'hello world' Out[61]: 14

In [46]: string2[0:4] In [63]: #modification of string


s = "I am a student"
Out[46]: 'hell'
s.replace('student', 'teacher')
In [47]: string2[0:5]
Out[63]: 'I am a teacher'
Out[47]: 'hello'
In [64]: address = "123 suhana apt, marathali, Bangalore"
In [48]: string2[0:7:2]
In [65]: address
Out[48]: 'hlow'
Out[65]: '123 suhana apt, marathali, Bangalore'
In [49]: string2[::-1]
In [66]: address.replace("apt", "Apartment")
Out[49]: 'dlrow olleh'
Out[66]: '123 suhana Apartment, marathali, Bangalore'
In [54]: s = "pwskills"
s[7] In [67]: text = "BRB, TTYL, LOL"
text.replace("BRB", "Be right back").replace("TTYL", "talk to you letter").replace
Out[54]: 's'
Out[67]: 'Be right back, talk to you letter, Laughing out loud' else:
print("Invalid")

In [68]: text = "Hello, World" Invalid

In [69]: text In [83]: document = "some_file.pdf"


if ".pdf" in document:
Out[69]: 'Hello, World' print("its a pdf file")
else:
print("Not")
In [70]: text.lower()
its a pdf file
Out[70]: 'hello, world'
In [84]: #string comparison
In [71]: text.upper()

Out[71]: 'HELLO, WORLD' str1 = "Hello"


str2 = "hello"

In [72]: text.title()
str1 == str2
Out[72]: 'Hello, World'
Out[84]: False
In [73]: text1 = "I am Is A Student"
text1.swapcase()
In [85]: str1 = "Hello"
str2 = "Hello"
Out[73]: 'i AM iS a sTUDENT'

In [75]: text1.capitalize() str1 == str2

Out[75]: 'I am is a student' Out[85]: True

In [77]: #String searching In [87]: str1 = "Hello"


str2 = "hello"

sentence = "I am a student at PWSkills"


"am" in sentence str1.lower() == str2.lower()

Out[77]: True Out[87]: True

In [80]: sentence = "I am a student at PWSkills" In [91]: reg_username = ["pw", "PW","pW"]


search_word = "am" new_user = "PW1"

if search_word in sentence: if new_user in reg_username:


print("The search word is present") print("already in use")
else: else:
print("Not") print("username is available")
The search word is present username is available

In [82]: email = "ajay12345gmail.com" In [3]: product_code = "P123"


scanned_code = input("scan the product code")
if "@" in email:
print("valid email") if product_code == scanned_code:
print("The price is 100") In [19]: des.strip()
else:
print("talk to reception") Out[19]: 'teacher'

talk to reception
In [17]: name
In [4]: #STRING ORDERING
Out[17]: 'Ajay'

In [6]: names = ["Ajay", "Nakula", "Bee"]


sorted(names) In [20]: sub.strip()

Out[6]: ['Ajay', 'Bee', 'Nakula'] Out[20]: 'data science'

In [7]: playlist = ["KKHH", "Magic", "Hello", "Magic"] In [29]: #Escape sequence >> special combination of characters used within a strings
sorted(playlist)
address = """123, sanmukha villa,
Out[7]: ['Hello', 'KKHH', 'Magic', 'Magic'] marathali,
bangalore """

In [8]: #common string operations


In [30]: print(address)

123, sanmukha villa,


input_str = " PWSKILLS " marathali,
input_str.strip() bangalore

Out[8]: 'PWSKILLS' In [31]: address = """123, sanmukha villa, \nmarathali, \nbangalore """

In [9]: input_str = " PW SKILLS " In [33]: print(address) #"\n">> to insert a new line character
input_str.strip()
123, sanmukha villa,
Out[9]: 'PW SKILLS' marathali,
bangalore
In [10]: csv_row = "Apple "
In [36]: #\t escape charcter
csv_row.strip()
table = "Name\tAge\tGrade\nAlice\t20\tA\nRam\t30\tA+"
print(table)
Out[10]: 'Apple'
Name Age Grade
In [11]: #string splitting Alice 20 A
data = "Ajay, data science, teacher" Ram 30 A+
data
In [42]: file_path = "C:\\USERS\\DOWNLOAD\\FILES.txt"
Out[11]: 'Ajay, data science, teacher' print(file_path)

C:\USERS\DOWNLOAD\FILES.txt
In [13]: teacher_info = data.split(',')
In [45]: #\' single quote escape
In [14]: teacher_info str1 = 'I can\'t believe its a friday'
str1
Out[14]: ['Ajay', ' data science', ' teacher']
Out[45]: "I can't believe its a friday"
In [15]: name = teacher_info[0]
sub = teacher_info[1] In [47]: #Carriage return \r >> moves the cursor to the beginning of line
des = teacher_info[2]
print("Hello, I am \rAjay. I am going to Delhi") In [73]: str1 = "pwskills"
str1.endswith("s")
Ajay. I am going to Delhi
Out[73]: True
In [56]: #string formatting >> creating string with placeholder for variables
username = "Shyam"
greeting = f"hello {username}, how are you?" In [74]: str1 = "pwskills"
print(greeting) str1.endswith("A")

hello Shyam, how are you? Out[74]: False

In [57]: #string formatting


In [75]: a = "acd123"
a.isalnum()
name = "PW SKILLS"
greeting = "Hello %s! wish you a wonderful day" %name
Out[75]: True
print(greeting)

Hello PW SKILLS! wish you a wonderful day In [77]: a = "acd"


a.isalnum()
In [59]: #.format
template = "Hello, {} Welcome to {}" Out[77]: True
message = template.format("Bijay", "Data Science")
print(message)
In [78]: s = "pwskills"
Hello, Bijay Welcome to Data Science len(s)

In [64]: #f strings (formatted string literals) Out[78]: 8


course = "pw data + frontend"
duration = 4 In [82]: count = 0
f"My course is {course} and its duration is {duration} years." for i in s:
#print(i)
Out[64]: 'My course is pw data + frontend and its duration is 4 years.' count = count+1
print(count)
In [66]: user_name = "Ajay"
8
post_date = "2024-02-22"
In [83]: s

print(f"Hello user {user_name}, Today is {post_date} post")


Out[83]: 'pwskills'
Hello user Ajay, Today is 2024-02-22 post
In [87]: list(range(len(s)))
In [68]: celsius = 30
f"{celsius} is equals to {(celsius * 9/5) + 32}F" Out[87]: [0, 1, 2, 3, 4, 5, 6, 7]

Out[68]: '30 is equals to 86.0F'


In [89]: for ch in range(len(s)):
print(ch)
In [70]: str1 = "pwskills" print(s[ch])
str1.startswith("p")

Out[70]: True

In [71]: str1 = "pwskills"


str1.startswith("q")

Out[71]: False
0 In [1]: #List are ordered collection of items
p #[]
1 #list is like a shopping bag which can store everything
w
2 In [2]: type([])
s
3 Out[2]: list
k
4
i In [3]: grocery_list = ["Milk", "Orange", 1, 2, 3, True, 2+4j, 2.3]
5
l In [4]: type(grocery_list)
6
l Out[4]: list
7
s In [5]: grocery_list

In [ ]: Out[5]: ['Milk', 'Orange', 1, 2, 3, True, (2+4j), 2.3]

In [6]: #lists are mutable

In [7]: grocery_list[0]

Out[7]: 'Milk'

In [8]: grocery_list[-1]

Out[8]: 2.3

In [9]: grocery_list[1:]

Out[9]: ['Orange', 1, 2, 3, True, (2+4j), 2.3]

In [10]: grocery_list[1:4]

Out[10]: ['Orange', 1, 2]

In [11]: movies = ["Action1", "Action2", "Action3","comedy1"]

In [12]: movies[0:3]

Out[12]: ['Action1', 'Action2', 'Action3']

In [13]: pages = ["Title page", "chap1", "chap2", "conclusion", "index"]

In [14]: pages[-1]

Out[14]: 'index'

In [15]: pages[-2]
Out[15]: 'conclusion' In [31]: lis1

Out[31]: ['Apple', 'brinjal', 'orange']


In [16]: queue = ["Ajay", "Bijay", "Sanjay", "Anjay"]
queue[-1]
In [32]: lis1.insert(1, "banana")
Out[16]: 'Anjay'
In [33]: lis1
In [17]: queue[-2]
Out[33]: ['Apple', 'banana', 'brinjal', 'orange']
Out[17]: 'Sanjay'
In [34]: bus_seat = ["Ajay", "Bob", "Sanjay"]
In [18]: lis1 = ["Apple", "Banana"] bus_seat.insert(1, "Ram")
lis1
In [35]: bus_seat
Out[18]: ['Apple', 'Banana']
Out[35]: ['Ajay', 'Ram', 'Bob', 'Sanjay']
In [19]: #append >> add element to the end of list
In [36]: #extend>> used to append elements from another iterable
lis1.append("orange") my_list = ["Apple", "Banana", "orange"]
brothers_list = ["brinjal", "potato"]
In [20]: lis1
my_list.extend(brothers_list)
Out[20]: ['Apple', 'Banana', 'orange']
In [37]: my_list
In [21]: playlist = []
playlist.append("Sare jhan se acha") Out[37]: ['Apple', 'Banana', 'orange', 'brinjal', 'potato']
playlist.append("Ae mere watan ke logo")
In [39]: my_list = ["Apple", "Banana", "orange"]
In [22]: playlist brothers_list = ["brinjal", "potato"]

Out[22]: ['Sare jhan se acha', 'Ae mere watan ke logo'] In [40]: my_list

In [24]: bookshelf = [] Out[40]: ['Apple', 'Banana', 'orange']


bookshelf.append("book1")
bookshelf.append("book2") In [41]: brothers_list

In [25]: bookshelf Out[41]: ['brinjal', 'potato']

Out[25]: ['book1', 'book2'] In [42]: #concatenate

In [26]: lis1 my_list + brothers_list

Out[26]: ['Apple', 'Banana', 'orange'] Out[42]: ['Apple', 'Banana', 'orange', 'brinjal', 'potato']

In [28]: lis1[1] = "brinjal" In [43]: #repeatation operation

"*" * 5
In [30]: lis1 #list are mutable
Out[43]: '*****'
Out[30]: ['Apple', 'brinjal', 'orange']
In [44]: "-" * 50 In [57]: #membership in , not in

Out[44]: '--------------------------------------------------'
grocery_list
In [46]: [0] * 10
Out[57]: ['Milk', 'Orange', 1, 2, 3, True, (2+4j), 2.3]
Out[46]: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
In [60]: "Milk" in grocery_list
In [47]: [1, 2, 3] * 10
Out[60]: True
Out[47]: [1,
2, In [61]: "Banana" in grocery_list
3,
1, Out[61]: False
2,
3, In [62]: "Banana" not in grocery_list
1,
2, Out[62]: True
3,
1,
In [63]: grocery_list
2,
3,
Out[63]: ['Milk', 'Orange', 1, 2, 3, True, (2+4j), 2.3]
1,
2,
3, In [75]: #shallow copy>> value will change with change in other list|
1, a = grocery_list
2,
3, In [65]: a
1,
2, Out[65]: ['Milk', 'Orange', 1, 2, 3, True, (2+4j), 2.3]
3,
1,
In [66]: grocery_list[0] = "Banana"
2,
3,
1, In [67]: grocery_list
2,
3, Out[67]: ['Banana', 'Orange', 1, 2, 3, True, (2+4j), 2.3]
1,
2, In [68]: a
3]
Out[68]: ['Banana', 'Orange', 1, 2, 3, True, (2+4j), 2.3]
In [50]: list(range(1, 6)) * 3
In [69]: #deep copy will not change with change in other list
Out[50]: [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
b = grocery_list.copy()

In [56]: msg = "your appointment is tomorrow \n"


In [70]: grocery_list
print(msg * 3)

your appointment is tomorrow Out[70]: ['Banana', 'Orange', 1, 2, 3, True, (2+4j), 2.3]


your appointment is tomorrow
your appointment is tomorrow In [71]: b

Out[71]: ['Banana', 'Orange', 1, 2, 3, True, (2+4j), 2.3]


In [72]: grocery_list[0] = "Guava" In [92]: del book_list

In [73]: grocery_list In [94]: book_list = ['Algorithm', 'Data Structure', 'Web dev']

Out[73]: ['Guava', 'Orange', 1, 2, 3, True, (2+4j), 2.3] In [95]: book_list

In [74]: b Out[95]: ['Algorithm', 'Data Structure', 'Web dev']

Out[74]: ['Banana', 'Orange', 1, 2, 3, True, (2+4j), 2.3] In [96]: book_list.clear()

In [76]: #sorting lists In [97]: book_list

book_list = ["Data Structure", "Algorithm", "Web dev"] Out[97]: []


sorted(book_list)

In [98]: book_list = ['Algorithm', 'Data Structure', 'Web dev']


Out[76]: ['Algorithm', 'Data Structure', 'Web dev']

In [99]: book_list.pop()
In [79]: book_list

Out[99]: 'Web dev'


Out[79]: ['Data Structure', 'Algorithm', 'Web dev']

In [100… book_list
In [80]: book_list.index("Algorithm")

Out[100… ['Algorithm', 'Data Structure']


Out[80]: 1

In [101… book_list = ['Algorithm', 'Data Structure', 'Web dev']


In [81]: book_list.index("Web dev")

Out[81]: 2 In [102… book_list.pop(1)

Out[102… 'Data Structure'


In [84]: book_list = ['Data Structure',"Data Structure", 'Algorithm', 'Web dev']

In [103… book_list
In [85]: book_list

Out[103… ['Algorithm', 'Web dev']


Out[85]: ['Data Structure', 'Data Structure', 'Algorithm', 'Web dev']

In [104… #list comprehension


In [86]: book_list.count('Data Structure')

Out[86]: 2 In [107… prices = [10, 20, 30, 40, 50]


doubled_price = []
for i in prices:
In [87]: book_list.remove('Data Structure')
doubled_price.append(i*2)

In [88]: book_list
In [108… doubled_price
Out[88]: ['Data Structure', 'Algorithm', 'Web dev']
Out[108… [20, 40, 60, 80, 100]

In [89]: book_list.sort()
In [110… doubled_price = [price * 2 for price in prices]

In [91]: book_list
In [111… doubled_price
Out[91]: ['Algorithm', 'Data Structure', 'Web dev']
Out[111… [20, 40, 60, 80, 100] In [127… #list as stack and queue

In [112… names = ["Ajay", "bijay", "sanjay"]


#stack >> last in first out principle > the last element added to the stack will be th

[name.capitalize() for name in names]

Out[112… ['Ajay', 'Bijay', 'Sanjay']

In [113… numbers = [1, 2, 3, 4, 5]


[num ** 2 for num in numbers]

Out[113… [1, 4, 9, 16, 25]

In [118… str1 = "doc1.ppt"

str1.split(".")[-1] In [128… stack_of_plates = []


stack_of_plates.append("plate1")
Out[118… 'ppt' stack_of_plates.append("plate2")
stack_of_plates.append("plate3")
In [119… file_name = ["doc1.ppt", "doc2.pdf", "doc3.jpg", "doc4.py"] stack_of_plates.append("plate4")

[file.split(".")[-1] for file in file_name] In [129… stack_of_plates

Out[119… ['ppt', 'pdf', 'jpg', 'py'] Out[129… ['plate1', 'plate2', 'plate3', 'plate4']

In [120… #conditional list comprehension In [130… stack_of_plates.pop()

Out[130… 'plate4'
email_address = ["[email protected]", "[email protected]", "[email protected]", "[email protected]"
In [131… stack_of_plates
[email for email in email_address if email.endswith("@yahoo.com")]
Out[131… ['plate1', 'plate2', 'plate3']
Out[120… ['[email protected]', '[email protected]']

In [132… browsing_history = []
In [123… #Nested list comprehension browsing_history.append("home_page")
browsing_history.append("about us")
browsing_history.append("contact")
pairs = []

In [133… browsing_history
for x in [1, 2, 3]:
for y in [4, 5, 6]:
Out[133… ['home_page', 'about us', 'contact']
pairs.append([x, y])

In [134… browsing_history.pop()
In [124… pairs

Out[134… 'contact'
Out[124… [[1, 4], [1, 5], [1, 6], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6]]

In [135… browsing_history
In [125… [[x, y] for x in [1, 2, 3] for y in [4, 5, 6]]

Out[135… ['home_page', 'about us']


Out[125… [[1, 4], [1, 5], [1, 6], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6]]
In [136… #Queue >> FIFO>> FIRST IN FIRST OUT print("printing" printjob)
#ORDERLY SEQUENTIAL MANNER
# TWO ENDS In [ ]:

In [137… from collections import deque

checkout = deque()

checkout.append("cus1")
checkout.append("cus2")
checkout.append("cus3")
checkout.append("cus4")

In [138… checkout

Out[138… deque(['cus1', 'cus2', 'cus3', 'cus4'])

In [139… while checkout:


customer = checkout.popleft()
print("serving", customer)

serving cus1
serving cus2
serving cus3
serving cus4

In [140… from queue import Queue

In [143… print_queue = Queue()

print_queue.put("Print job 1")


print_queue.put("Print job 2")
print_queue.put("Print job 3")

while not print_queue.empty():


print_job = print_queue.get()
In [1]: t = () Out[13]: 2

In [2]: type(t) In [14]: tuple1.index(2)

Out[2]: tuple Out[14]: 4

In [3]: #Tuples are ordered collection of elements, heterogenous In [15]: tuple1.index('pwskills')


#Tuples are immutable
Out[15]: 0
In [4]: tuple1 = ("pwskills", 7+3j, True, 1, 2, 1, 1, 2,2.2)
In [18]: print(tuple1 * 2)
In [5]: type(tuple1)
('pwskills', (7+3j), True, 1, 2, 1, 1, 2, 2.2, 'pwskills', (7+3j), True, 1, 2,
Out[5]: tuple 1, 1, 2, 2.2)

In [20]: tuple1[0:4]
In [6]: tuple1[0]
Out[20]: ('pwskills', (7+3j), True, 1)
Out[6]: 'pwskills'

In [23]: tuple1[::-1]
In [7]: #Tuples are immutable
tuple1[0] = "data" Out[23]: (2.2, 2, 1, 1, 2, 1, True, (7+3j), 'pwskills')

---------------------------------------------------------------------------
TypeError Traceback (most recent call last) In [25]: tuple1[-1]
Cell In[7], line 2
1 #Tuples are immutable Out[25]: 2.2
----> 2 tuple1[0] = "data"
In [28]: for i in tuple1:
TypeError: 'tuple' object does not support item assignment print(i, type(i))

In [8]: emp_id = (1, 2, 3, 4, 5) pwskills <class 'str'>


(7+3j) <class 'complex'>
True <class 'bool'>
In [10]: emp_id[0] = 100 #immutable 1 <class 'int'>
2 <class 'int'>
---------------------------------------------------------------------------
1 <class 'int'>
TypeError Traceback (most recent call last)
1 <class 'int'>
Cell In[10], line 1
2 <class 'int'>
----> 1 emp_id[0] = 100
2.2 <class 'float'>

TypeError: 'tuple' object does not support item assignment In [29]: t1 = (1, 2, 100, 4, 5)

In [11]: tuple1
In [30]: max(t1)
Out[11]: ('pwskills', (7+3j), True, 1, 2, 1, 1, 2, 2.2)
Out[30]: 100

In [12]: tuple1.count(1)
In [31]: min(t1)
Out[12]: 4
Out[31]: 1

In [13]: tuple1.count(2)
In [32]: t2 = (2, 3, 500)
In [34]: t3 = (t1, t2) Out[47]: (1, 2, 100, 4, 5, 2, 3, 500)

In [35]: t3 In [48]: #Set>> sets are collection of unique and unordered elements
#dont allow duplicate elements>> not mauintain any order and it will not be indexed
Out[35]: ((1, 2, 100, 4, 5), (2, 3, 500))

In [49]: s = {}
In [36]: del t3

In [50]: s
In [37]: t3
Out[50]: {}
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[37], line 1 In [51]: type(s)
----> 1 t3
Out[51]: dict
NameError: name 't3' is not defined
In [52]: s = {2, 3, 4}
In [39]: len(t1)
In [53]: type(s)
Out[39]: 5
Out[53]: set
In [40]: t1
In [54]: s = {1, 1, 1, 2, 1, 2, 2, 1, "ajay", "ajay", "Ajay"}
Out[40]: (1, 2, 100, 4, 5)

In [55]: s
In [41]: 100 in t1
Out[55]: {1, 2, 'Ajay', 'ajay'}
Out[41]: True

In [57]: list1 = [2, 3, 4, 4, 4, 5, 5]


In [42]: tuple1 s = set(list1)

Out[42]: ('pwskills', (7+3j), True, 1, 2, 1, 1, 2, 2.2)


In [59]: list(s)

In [43]: "pwskills" in tuple1 Out[59]: [2, 3, 4, 5]

Out[43]: True
In [61]: s[0]

In [44]: "pwskills" not in tuple1 ---------------------------------------------------------------------------


TypeError Traceback (most recent call last)
Out[44]: False Cell In[61], line 1
----> 1 s[0]
In [45]: t1
TypeError: 'set' object is not subscriptable
Out[45]: (1, 2, 100, 4, 5)
In [62]: {1,1, 2, 2, 2, 3, 3, 100}
In [46]: t2
Out[62]: {1, 2, 3, 100}
Out[46]: (2, 3, 500)
In [63]: s[1]
In [47]: t1+t2
--------------------------------------------------------------------------- In [76]: s
TypeError Traceback (most recent call last)
Cell In[63], line 1 Out[76]: {(1, 2, 3), 1, 100, 2, 3}
----> 1 s[1]
In [77]: s.pop()
TypeError: 'set' object is not subscriptable
Out[77]: 1
In [64]: {1, 2, 3, 2, 2, 3, 3, [1, 2, 3]}
In [78]: s
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Out[78]: {(1, 2, 3), 100, 2, 3}
Cell In[64], line 1
----> 1 {1, 2, 3, 2, 2, 3, 3, [1, 2, 3]}
In [80]: s.remove(2)
TypeError: unhashable type: 'list'
In [81]: s
In [66]: s = {1, 2, 3, 2, 2, 3, 3, (1, 2, 3)}
Out[81]: {(1, 2, 3), 100, 3}
In [68]: s[0]
In [83]: s.update("2") #update will not work with integers
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
In [84]: s
Cell In[68], line 1
----> 1 s[0]
Out[84]: {(1, 2, 3), 100, '2', 3}

TypeError: 'set' object is not subscriptable


In [85]: del s
In [69]: s[::-1]
In [87]: s = {(1, 2, 3), 100, '2', 3}
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
In [89]: s.clear()
Cell In[69], line 1
----> 1 s[::-1]
In [90]: s
TypeError: 'set' object is not subscriptable
Out[90]: set()
In [72]: for i in s:
print(i) In [91]: s

1
Out[91]: set()
2
3
(1, 2, 3) In [92]: s = {(1, 2, 3), 100, '2', 3}

In [73]: s In [93]: s

Out[73]: {(1, 2, 3), 1, 2, 3} Out[93]: {(1, 2, 3), 100, '2', 3}

In [74]: len(s) In [94]: s.discard('2')

Out[74]: 4
In [95]: s

In [75]: s.add(100) Out[95]: {(1, 2, 3), 100, 3}


In [98]: s.remove(5) #remove will throw an error if the given element is not present in set Out[108… {'hiking', 'reading'}

---------------------------------------------------------------------------
KeyError Traceback (most recent call last) In [109… #symmetric difference
Cell In[98], line 1 s1 ^ s2
----> 1 s.remove(5) #remove will throw an error if the given element is not pre
sent in set Out[109… {'hiking', 'photography', 'reading', 'travelling'}

KeyError: 5 In [110… #frozen sets

In [99]: s In [111… s

Out[99]: {(1, 2, 3), 100, 3} Out[111… {(1, 2, 3), 100, 3}

In [100… s.discard(5) #error will not be thrown if element is not present In [112… s.add(123)

In [101… s In [113… s

Out[101… {(1, 2, 3), 100, 3} Out[113… {(1, 2, 3), 100, 123, 3}

In [102… #Set operations In [115… #frozen set >> immutable version of set., can not be changed added or removed
#Union: combines elements from two sets excluding duplicates
#Intersection: only common elements btw sets my_frozenset = frozenset([1, 2, 3, 4, 4, 5, 5])
#difference: return the elements that is present in first set and not in second
#symmetric difference: returns elements that are present in either of sets but not in both
In [116… type(my_frozenset)

In [103… s1 = {"hiking", "reading", "coding"} Out[116… frozenset


s2 = {"coding", "photography", "travelling"}

In [117… my_frozenset.add(5, 6, 7)
In [104… s1
---------------------------------------------------------------------------
Out[104… {'coding', 'hiking', 'reading'} AttributeError Traceback (most recent call last)
Cell In[117], line 1
In [105… s2 ----> 1 my_frozenset.add(5, 6, 7)

Out[105… {'coding', 'photography', 'travelling'} AttributeError: 'frozenset' object has no attribute 'add'

In [118… my_frozenset.pop()
In [106… #intersection >> &
---------------------------------------------------------------------------
s1 & s2
AttributeError Traceback (most recent call last)
Cell In[118], line 1
Out[106… {'coding'}
----> 1 my_frozenset.pop()

In [107… #union AttributeError: 'frozenset' object has no attribute 'pop'


s1 | s2
In [ ]: fo
Out[107… {'coding', 'hiking', 'photography', 'reading', 'travelling'}

In [108… #difference
s1 - s2
In [2]: #dictionary is a data structure that stores data as key value pair Out[22]: {101: 'abc'}
#Unordered, Keys are unique and immutable

In [23]: d = {1.2:"abc"}
In [3]: d = {}
type(d)
In [24]: d
Out[3]: dict
Out[24]: {1.2: 'abc'}

In [4]: d = {"name": "Ajay", "email": "[email protected]", "contact" : 1234}


In [25]: d = {True:"abc"}

In [6]: type(d)
In [26]: d
Out[6]: dict
Out[26]: {True: 'abc'}

In [7]: d
In [27]: d = {#:"abc"}
Out[7]: {'name': 'Ajay', 'email': '[email protected]', 'contact': 1234}
Cell In[27], line 1
d = {#:"abc"}
In [10]: l = [100, 200, 300] ^
SyntaxError: incomplete input
In [13]: d['name']
In [28]: d = {@:"abc"}
Out[13]: 'Ajay'
Cell In[28], line 1
d = {@:"abc"}
In [14]: d['email']
^
SyntaxError: invalid syntax
Out[14]: '[email protected]'
In [29]: d = {[1, 2,3]:"abc"}
In [15]: d['name'] = "bijay"
---------------------------------------------------------------------------
In [16]: d TypeError Traceback (most recent call last)
Cell In[29], line 1
Out[16]: {'name': 'bijay', 'email': '[email protected]', 'contact': 1234} ----> 1 d = {[1, 2,3]:"abc"}

TypeError: unhashable type: 'list'


In [17]: d = {"name": "Ajay", "email": "[email protected]", "contact" : 1234, "name": "ajay"}
In [30]: d = {(1, 2,3):"abc"}
In [18]: d
In [31]: d
Out[18]: {'name': 'ajay', 'email': '[email protected]', 'contact': 1234}
Out[31]: {(1, 2, 3): 'abc'}
In [19]: d = {1:"abc"}
In [32]: d = {{1, 2,3}:"abc"}
In [20]: d
---------------------------------------------------------------------------
Out[20]: {1: 'abc'} TypeError Traceback (most recent call last)
Cell In[32], line 1
In [21]: d = {101:"abc"} ----> 1 d = {{1, 2,3}:"abc"}

TypeError: unhashable type: 'set'


In [22]: d
In [33]: d = {{"key":123}:"abc"} In [50]: del d

--------------------------------------------------------------------------- In [51]: d
TypeError Traceback (most recent call last)
Cell In[33], line 1 ---------------------------------------------------------------------------
----> 1 d = {{"key":123}:"abc"} NameError Traceback (most recent call last)
Cell In[51], line 1
TypeError: unhashable type: 'dict' ----> 1 d

In [34]: d = {"name": "Ajay", "email": "[email protected]", "contact" : 1234, "name": "ajay"} NameError: name 'd' is not defined

In [35]: d In [52]: d = {"name": ["Ajay", "Bijay", "Sanjay"], "course": ("ds", "ml")}

Out[35]: {'name': 'ajay', 'email': '[email protected]', 'contact': 1234} In [53]: d.clear()

In [36]: d["name"] = "data science" In [54]: d

In [37]: d Out[54]: {}

Out[37]: {'name': 'data science', 'email': '[email protected]', 'contact': 1234} In [55]: d = {"name": ["Ajay", "Bijay", "Sanjay"], "course": ("ds", "ml")}
len(d)
In [38]: d = {"name": ["Ajay", "Bijay", "Sanjay"], "course": ("ds", "ml")}
Out[55]: 2
In [39]: d
In [56]: d
Out[39]: {'name': ['Ajay', 'Bijay', 'Sanjay'], 'course': ('ds', 'ml')}
Out[56]: {'name': ['Ajay', 'Bijay', 'Sanjay'], 'course': ('ds', 'ml')}
In [42]: d['name'][1]
In [57]: d.keys()
Out[42]: 'Bijay'
Out[57]: dict_keys(['name', 'course'])
In [44]: d["date_of_start"] = "15th March"
In [58]: d.values()
In [45]: d
Out[58]: dict_values([['Ajay', 'Bijay', 'Sanjay'], ('ds', 'ml')])
Out[45]: {'name': ['Ajay', 'Bijay', 'Sanjay'],
'course': ('ds', 'ml'), In [59]: d.items()
'date_of_start': '15th March'}
Out[59]: dict_items([('name', ['Ajay', 'Bijay', 'Sanjay']), ('course', ('ds', 'ml'))])
In [46]: d['name'] = "Rakesh"
In [60]: d1 = d.copy()
In [47]: d
In [61]: d1
Out[47]: {'name': 'Rakesh', 'course': ('ds', 'ml'), 'date_of_start': '15th March'}
Out[61]: {'name': ['Ajay', 'Bijay', 'Sanjay'], 'course': ('ds', 'ml')}
In [48]: del d['date_of_start']
In [62]: del d1
In [49]: d
In [64]: d
Out[49]: {'name': 'Rakesh', 'course': ('ds', 'ml')}
Out[64]: {'name': ['Ajay', 'Bijay', 'Sanjay'], 'course': ('ds', 'ml')} Out[77]: {'Arun': 80, 'Ajay': 95, 'Bob': 90}

In [66]: d.pop('course') In [82]: for i in zip(students, marks):


print(i)
Out[66]: ('ds', 'ml')
('Arun', 80)
('Ajay', 95)
In [67]: d ('Bob', 90)

Out[67]: {'name': ['Ajay', 'Bijay', 'Sanjay']} In [85]: {student:marks for student, marks in zip(students, marks)}

In [68]: d Out[85]: {'Arun': 80, 'Ajay': 95, 'Bob': 90}

Out[68]: {'name': ['Ajay', 'Bijay', 'Sanjay']} In [86]: user_id = [1, 2, 3]


user_name = ["a21", "a22", "a33"]
In [69]: d1 = {"course": "DS", "start": "20th mar"} {u_id:u_name for u_id, u_name in zip(user_id, user_name)}

In [70]: d1 Out[86]: {1: 'a21', 2: 'a22', 3: 'a33'}

Out[70]: {'course': 'DS', 'start': '20th mar'} In [87]: employee_records = {


'E001': {'name': 'John Doe', 'department': 'Engineering', 'salary': 75000},
In [71]: d.update(d1) 'E002': {'name': 'Jane Smith', 'department': 'Marketing', 'salary': 65000},
'E003': {'name': 'David Lee', 'department': 'Finance', 'salary': 80000}
}
In [72]: d

Out[72]: {'name': ['Ajay', 'Bijay', 'Sanjay'], 'course': 'DS', 'start': '20th mar'} In [89]: employee_records['E001']

Out[89]: {'name': 'John Doe', 'department': 'Engineering', 'salary': 75000}


In [73]: d['start']

Out[73]: '20th mar' In [90]: restaurant_menu = {


'Dish1': {'name': 'Pasta Carbonara', 'price': 15.99, 'description': 'Creamy pasta
'Dish2': {'name': 'Chicken Caesar Salad', 'price': 12.50, 'description': 'Grilled
In [74]: d.get('start')
'Dish3': {'name': 'Margherita Pizza', 'price': 14.00, 'description': 'Pizza topped
}
Out[74]: '20th mar'

In [91]: restaurant_menu['Dish1']
In [75]: d.fromkeys((1, 2, 3), ('a', 'b', 'c'))
Out[91]: {'name': 'Pasta Carbonara',
Out[75]: {1: ('a', 'b', 'c'), 2: ('a', 'b', 'c'), 3: ('a', 'b', 'c')}
'price': 15.99,
'description': 'Creamy pasta with bacon and parmesan'}
In [79]: #dictionary comprehension
In [92]: restaurant_menu
students = ['Arun', 'Ajay', 'Bob']
marks = [80, 95, 90] Out[92]: {'Dish1': {'name': 'Pasta Carbonara',
'price': 15.99,
student_marks = {} 'description': 'Creamy pasta with bacon and parmesan'},
'Dish2': {'name': 'Chicken Caesar Salad',
for student, mark in zip(students, marks): 'price': 12.5,
student_marks[student] = mark 'description': 'Grilled chicken with romaine lettuce and Caesar dressing'},
'Dish3': {'name': 'Margherita Pizza',
In [77]: student_marks 'price': 14.0,
'description': 'Pizza topped with tomato, mozzarella, and basil'}}
In [93]: #Dictionary view objects In [1]: print("hello world")
restaurant_menu.keys()
hello world
Out[93]: dict_keys(['Dish1', 'Dish2', 'Dish3'])
In [2]: len("hello")

In [94]: restaurant_menu.values() Out[2]: 5

Out[94]: dict_values([{'name': 'Pasta Carbonara', 'price': 15.99, 'description': 'Crea


In [3]: type(5)
my pasta with bacon and parmesan'}, {'name': 'Chicken Caesar Salad', 'price':
12.5, 'description': 'Grilled chicken with romaine lettuce and Caesar dressin
Out[3]: int
g'}, {'name': 'Margherita Pizza', 'price': 14.0, 'description': 'Pizza topped
with tomato, mozzarella, and basil'}])
In [4]: #functions
In [95]: restaurant_menu.items() #inbuilt>> print, len, type
#userdefined
Out[95]: dict_items([('Dish1', {'name': 'Pasta Carbonara', 'price': 15.99, 'descriptio
n': 'Creamy pasta with bacon and parmesan'}), ('Dish2', {'name': 'Chicken Cae In [5]: #functions>>it is a block of code that performs some specific computations
sar Salad', 'price': 12.5, 'description': 'Grilled chicken with romaine lettu #it keeps your code neat and clean,organise, reusable
ce and Caesar dressing'}), ('Dish3', {'name': 'Margherita Pizza', 'price': 1
4.0, 'description': 'Pizza topped with tomato, mozzarella, and basil'})])
In [6]: int(2.25)
In [ ]:
Out[6]: 2

In [7]: float(2)

Out[7]: 2.0

In [9]: import math as m


m.ceil(6.5)

Out[9]: 7

In [10]: m.floor(3.5)

Out[10]: 3

In [11]: #syntax of function


#def func():
#do something
#do something
#return

In [12]: print("welcome to class Rahul")


print("welcome to class Shweta")
print("welcome to class Amruta")

welcome to class Rahul


welcome to class Shweta
welcome to class Amruta

In [13]: def greet(n):


print("welcome to class", n)
In [17]: greet("jaya") In [37]: a

welcome to class jaya Out[37]: 'this is my first function'

In [18]: def func():


print("this is my first function") In [38]: b

Out[38]: 2
In [21]: "this is my first function" + " in Python"

Out[21]: 'this is my first function in Python' In [39]: c

Out[39]: 4
In [22]: func() + " in Python"

this is my first function In [40]: d


---------------------------------------------------------------------------
TypeError Traceback (most recent call last) Out[40]: (3+7j)
Cell In[22], line 1
----> 1 func() + " in Python" In [41]: e

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' Out[41]: True

In [25]: func()
In [43]: a, b, c, d, e = func()
this is my first function
In [44]: func()[2]
In [26]: type(func())
Out[44]: 4
this is my first function
Out[26]: NoneType
In [45]: def func():
calc = 2+3+6*5
In [27]: def func(): return calc
return "this is my first function"
In [47]: type(func())
In [28]: func()+" in Python"
Out[47]: int
Out[28]: 'this is my first function in Python'
In [48]: def square_no(a): #a is called as arguement
In [29]: def func(): return a*a
return "this is my first function", 2, 4, 3+7j, True
In [52]: square_no(60000)
In [30]: func()
Out[52]: 3600000000
Out[30]: ('this is my first function', 2, 4, (3+7j), True)
In [53]: def sum_(a, b):
In [31]: a = func() return a+b

In [33]: type(a) In [54]: sum_(3, 4)

Out[33]: tuple Out[54]: 7

In [36]: a, b, c, d, e = func() In [55]: sum_("pw", "skills")


Out[55]: 'pwskills'
return n

In [56]: sum_([1, 2, 3], [4, 5, 6])


In [84]: only_numeric([1, 2, 3, 4.5, 5, "Ajay", "pwskills", True, [1, 2, 3, 4]])
Out[56]: [1, 2, 3, 4, 5, 6]
Out[84]: [1, 2, 3, 4.5, 5]

In [57]: sum_(b = [1, 2, 3], a = [4, 5, 6])


In [85]: def only_numeric(a):
Out[57]: [4, 5, 6, 1, 2, 3] n = []
for i in a:
if type(i) == list:
In [58]: sum_(b = "pw", a = "skills")
for j in i:
if type(j) == int or type(j) == float:
Out[58]: 'skillspw'
n.append(j)
else:
In [66]: def sum_1(a, b, c): if type(i) == int or type(i) == float:
return a+b+c n.append(i)

In [68]: sum_1(1, 2, 4) return n

Out[68]: 7 In [86]: only_numeric([1, 2, 3, 4.5, 5, "Ajay", "pwskills", True, [1, 2, 3, 4]])

In [70]: #default arguement Out[86]: [1, 2, 3, 4.5, 5, 1, 2, 3, 4]

def sum_2(a=0, b=0, c=0): In [87]: def sum_(a, b):


return a+b+c return a+b

In [73]: sum_2(a = 2, b = 3) In [89]: sum_(2, 3, 4)

Out[73]: 5 ---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
In [74]: sum_2(3, 5) Cell In[89], line 1
----> 1 sum_(2, 3, 4)
Out[74]: 8
TypeError: sum_() takes 2 positional arguments but 3 were given

In [75]: def add_two_nos():


In [90]: #variable length arguement
a = int(input("enter the first no"))
b = int(input("enter the second no"))
def sum_(*args):
return a+b
s = 0
for i in args:
In [76]: add_two_nos() s = s+i
return s
Out[76]: 6
In [93]: sum_(1,2,3, 4, 5, 6, 7, 8)
In [77]: #write a function that take list as input and retrun me all numeric values
Out[93]: 36
In [80]: def only_numeric(a):
n = [] In [94]: def test1(*args):
for i in a: return args
if type(i) == int or type(i) == float:
n.append(i)
In [95]: test1(1, 2.3, 4, 4.5, "Ajay", [1,2,3], (12,3), True) In [116… def test1(*ajay, **bijay):
return ajay, bijay
Out[95]: (1, 2.3, 4, 4.5, 'Ajay', [1, 2, 3], (12, 3), True)
In [117… test1(1, 2, 3, a = 100, c=200)
In [96]: def test1(*args, a):
return args, a Out[117… ((1, 2, 3), {'a': 100, 'c': 200})

In [98]: test1(1, 2.3, 4, 4.5, "Ajay", [1,2,3], (12,3), True, a = "ram") In [118… #Python namespace
def greet():
Out[98]: ((1, 2.3, 4, 4.5, 'Ajay', [1, 2, 3], (12, 3), True), 'ram') message = "hello, welcome" #message is a local variable
print(message)
In [99]: def return_list(*args):
l = [] In [119… greet()
for i in args:
if type(i) == list: hello, welcome
l.append(i)
In [120… print(message)
return l
---------------------------------------------------------------------------
In [102… return_list(1, 2.3, 4, 4.5, "Ajay", [1,2,3],[4, 5, 6, 7], (12,3), True) NameError Traceback (most recent call last)
Cell In[120], line 1
Out[102… [[1, 2, 3], [4, 5, 6, 7]] ----> 1 print(message)

In [103… def team(name, project): NameError: name 'message' is not defined


return f"{name} is working on {project}."
In [121… subpart = " to the course." #global variable>> can be accessed in and outside the func
def greet():
In [104… team(name = "Ajay", project="IR")
message = "hello, welcome" + subpart
print(message)
Out[104… 'Ajay is working on IR.'

In [122… greet()
In [105… #it should accept any no of arguement
#treated as key value pair hello, welcome to the course.

In [106… def kwarg_func(**kwargs): In [123… print(subpart)


return kwargs
to the course.

In [111… kwarg_func(a = 2, b=3, c= 6, d=[1,23], e=(12,3, 4), f=[2,3,4]) In [124… print(message)

Out[111… {'a': 2, 'b': 3, 'c': 6, 'd': [1, 23], 'e': (12, 3, 4), 'f': [2, 3, 4]} ---------------------------------------------------------------------------
NameError Traceback (most recent call last)
In [112… #write a function which takes variable key word argument and return only the values which is a list Cell In[124], line 1
----> 1 print(message)
In [113… def test(**kwargs):
NameError: name 'message' is not defined
for i in kwargs.keys():
if type(kwargs[i]) ==list:
In [131… #function inside function
return i, kwargs[i]

In [115… test(a = 2, b=3, c= 6, d=[1,23], e=(12,3, 4), f=(2,3,4)) def marks_in_subjects(**kwargs):


def total_marks(marks_list):
Out[115… ('d', [1, 23]) return sum(marks_list)
marks_list = []
for subject, marks in kwargs.items(): This function returns the power of no
marks_list.append(marks) Args:
return total_marks(marks_list) num(int): insert any integer value
power(int): insert any integer value
In [132… marks_in_subjects(a = 37, b=46, c= 23) Returns:
integer: power of number
Out[132… 106

In [ ]:
In [133… #calling from outside
def total_marks(marks_list):
return sum(marks_list)
def marks_in_subjects(**kwargs):
marks_list = []
for subject, marks in kwargs.items():
marks_list.append(marks)
return total_marks(marks_list)

In [134… marks_in_subjects(a = 37, b=46, c= 23)

Out[134… 106

In [137… def find_power(num, power):


""" This function returns the power of no
Args:
num(int): insert any integer value
power(int): insert any integer value
Returns:
integer: power of number
"""
return num**power

In [138… find_power(2, 3)

Out[138… 8

In [139… help(find_power)

Help on function find_power in module __main__:

find_power(num, power)
This function returns the power of no
Args:
num(int): insert any integer value
power(int): insert any integer value
Returns:
integer: power of number

In [141… print(find_power.__doc__)
In [1]: #lambda >> anonymous function In [18]: fact_num(5)
#syntax: lambda arguements: expression
Out[18]: 120
In [2]: def square(x):
return x**2 In [19]: #map>> executes a specified function for each of item of an iterable
#syntax > map(func, *iterables)
In [3]: square(2)
In [20]: help(map)
Out[3]: 4
Help on class map in module builtins:

In [5]: sq_lambda = lambda x: x**2 class map(object)


| map(func, *iterables) --> map object
In [6]: sq_lambda(5) |
| Make an iterator that computes the function using arguments from
Out[6]: 25 | each of the iterables. Stops when the shortest iterable is exhausted.
|
In [7]: add = lambda a,b: a+b | Methods defined here:
add(3, 4) |
| __getattribute__(self, name, /)
Out[7]: 7 | Return getattr(self, name).
|
| __iter__(self, /)
In [9]: is_even = lambda x: x%2 == 0
| Implement iter(self).
is_even(21)
|
| __next__(self, /)
Out[9]: False
| Implement next(self).
|
In [12]: x = ["Python", "Data Science", "Ajay"] | __reduce__(...)
sorted_words = sorted(x, key = lambda x: len(x)) | Return state information for pickling.
print(sorted_words) |
| ----------------------------------------------------------------------
['Ajay', 'Python', 'Data Science']
| Static methods defined here:
|
In [13]: fib = lambda n: n if n <=1 else fib(n-1) + fib(n-2)
| __new__(*args, **kwargs) from builtins.type
[fib(i) for i in range(10)]
| Create and return a new object. See help(type) for accurate signature.
Out[13]: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]

In [21]: l = [1, 2, 3, 4, 5]
In [14]: #factorial of 5 = 5*4*3*2*1 #factorial of 0 = 1 #!5 means factorial 5
def square(l):
In [15]: def fact_num(n): sq =[]
if n==0: for i in l:
return 1 sq.append(i**2)
else: return sq
return n*fact_num(n-1)
In [22]: square(l)
In [16]: fact_num(5)
Out[22]: [1, 4, 9, 16, 25]
Out[16]: 120
In [23]: def sq(x):
In [17]: fact_num = lambda n: 1 if n==0 else n*fact_num(n-1) return x**2
In [24]: l In [35]: words = ["python", "Ajay"]
list(map(str.capitalize, words))
Out[24]: [1, 2, 3, 4, 5]
Out[35]: ['Python', 'Ajay']
In [26]: list(map(sq, l))
In [38]: grades = ["A", "B", "C", "D"]
Out[26]: [1, 4, 9, 16, 25] list(map(lambda grade: 4 if grade == "A" else (3 if grade == "B" else 2), grades

In [27]: def add(x): Out[38]: [4, 3, 2, 2]


return x + 10
In [39]: #reduce >> folding/reduction
list(map(add, l))
from functools import reduce
Out[27]: [11, 12, 13, 14, 15]
In [40]: l = [2, 1, 3, 4, 5, 6]
In [28]: def sq(x): reduce(lambda x, y: x+y, l)
return x**2
Out[40]: 21
list(map(sq, l))
In [41]: def add(x, y):
Out[28]: [1, 4, 9, 16, 25] return x+y
reduce(add, l)
In [29]: #using lambda
list(map(lambda x: x**2, l)) Out[41]: 21

Out[29]: [1, 4, 9, 16, 25] In [42]: l = [2, 1, 3, 4, 5, 6]


reduce(lambda x, y, z: x+y+z, l)
In [30]: list(map(lambda x: x+10, l))
---------------------------------------------------------------------------
Out[30]: [11, 12, 13, 14, 15] TypeError Traceback (most recent call last)
Cell In[42], line 2
In [31]: a = lambda x: x**2 1 l = [2, 1, 3, 4, 5, 6]
list(map(a, l)) ----> 2 reduce(lambda x, y, z: x+y+z, l)

Out[31]: [1, 4, 9, 16, 25] TypeError: <lambda>() missing 1 required positional argument: 'z'

In [43]: reduce(lambda x, y: x+y, [])


In [32]: l = ["1", "2", "3", "100"]
list(map(lambda x: int(x), l)) ---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Out[32]: [1, 2, 3, 100] Cell In[43], line 1
----> 1 reduce(lambda x, y: x+y, [])
In [33]: l1 = [100, 200, 300, 400]
l2 = [1, 2, 3, 4] TypeError: reduce() of empty iterable with no initial value
list(map(lambda x, y: x+y, l1, l2))
In [44]: reduce(lambda x, y: x+y, [1])
Out[33]: [101, 202, 303, 404]
Out[44]: 1
In [34]: s = "pwskills"
list(map(lambda x: x.upper(), s)) In [45]: reduce(lambda x, y: x*y, [1])

Out[34]: ['P', 'W', 'S', 'K', 'I', 'L', 'L', 'S'] Out[45]: 1
In [46]: l list(filter(lambda x: len(x) >3, s))

Out[46]: [2, 1, 3, 4, 5, 6] Out[62]: ['Ajay', 'Data', 'pwskills']

In [48]: reduce(lambda x, y: x*y, l) In [63]: def check_even(num):


if num % 2 == 0:
Out[48]: 720 return True
return False
In [49]: words = ["Data", "Science", "Courses"]
reduce(lambda x, y : x + " " +y, words) In [66]: num = [1, 2, 4, 6, 8, 10]
list(filter(check_even, num))
Out[49]: 'Data Science Courses'
Out[66]: [2, 4, 6, 8, 10]
In [50]: numbers = [1, 2, 5, 3, 100, 1000, 6, 10000]
reduce(lambda x, y: x if x>y else y, numbers) In [ ]:

Out[50]: 10000

In [51]: def factorial(n):


return reduce(lambda x, y: x*y, range(1, n+1))

In [52]: factorial(5)

Out[52]: 120

In [53]: #filter function >> is used to filter elements from an iterable based on some certain condition
#syntax >> filter(function, iterable)

In [54]: l

Out[54]: [2, 1, 3, 4, 5, 6]

In [56]: list(filter(lambda x: x%2 == 0, l))

Out[56]: [2, 4, 6]

In [57]: list(filter(lambda x: x%2 != 0, l))

Out[57]: [1, 3, 5]

In [59]: l1 = [-2, -1, 4, 5, 6]


list(filter(lambda x: x < 0, l1))

Out[59]: [-2, -1]

In [60]: list(filter(lambda x: x >= 0, l1))

Out[60]: [4, 5, 6]

In [62]: s = ["Ajay", "CMU", "Data", "pwskills"]


In [1]: #iterators ---------------------------------------------------------------------------
for i in "pwskills": TypeError Traceback (most recent call last)
print(i) Cell In[8], line 1
----> 1 iter(5)
p
w
TypeError: 'int' object is not iterable
s
k
In [10]: for i in s:
i
print(i)
l
l p
s w
s
In [2]: lis = [1,2, 3, 4, "Ajay"] k
for i in lis: i
print(i) l
l
1
s
2
3
In [14]: iter(s)
4
Ajay
Out[14]: <str_iterator at 0x7ffa7076f1c0>
In [3]: for i in 5:
print(i) In [12]: a = iter(s)

--------------------------------------------------------------------------- In [15]: next(a)


TypeError Traceback (most recent call last)
Cell In[3], line 1 Out[15]: 'p'
----> 1 for i in 5:
2 print(i)
In [16]: next(a)
TypeError: 'int' object is not iterable
Out[16]: 'w'
In [4]: #iterator is an object that is used to iterate over iterable objects
#list, tuple, dict, string, sets In [17]: next(a)

Out[17]: 's'
In [5]: s = "pwskills"

iter(s) In [18]: next(a)

Out[5]: <str_iterator at 0x7ffa706bbf70> Out[18]: 'k'

In [7]: iter(lis) In [19]: next(a)

Out[7]: <list_iterator at 0x7ffa706b8b20> Out[19]: 'i'

In [8]: iter(5) In [20]: next(a)

Out[20]: 'l'

In [21]: next(a)
Out[21]: 'l' In [35]: next(a)

Out[35]: 'j'
In [22]: next(a)

Out[22]: 's' In [36]: next(a)

Out[36]: 'a'
In [24]: for i in s:
print(i)
In [37]: next(a)
p
w Out[37]: 'y'
s
k In [38]: next(a)
i
l ---------------------------------------------------------------------------
l StopIteration Traceback (most recent call last)
s Cell In[38], line 1
----> 1 next(a)
In [26]: while True:
try: StopIteration:
s = iter(s)
item = next(s) In [39]: a = iter([1, 2, 3, 4])
print(item) next(a)
except StopIteration:
break Out[39]: 1
p
w In [40]: next(a)
s
k Out[40]: 2
i
l In [41]: next(a)
l
s Out[41]: 3

In [27]: #iterable, iterator, iterate


In [42]: next(a)
for i in "pwskills":
print(i)
Out[42]: 4
p
w In [45]: t = iter((1,2,3, 4, 5))
s
k
In [46]: next(t)
i
l
Out[46]: 1
l
s
In [47]: next(t)
In [33]: s = "Ajay" #iterable>>object which can be iterated, ##iterator> To iterate the iterable is to be converted to iterator
a = iter(s) Out[47]: 2

In [34]: next(a) In [48]: next(t)

Out[34]: 'A' Out[48]: 3


In [49]: s = iter({1, 2, 3, }) In [62]: next(gen)
next(s)
Out[62]: 0
Out[49]: 1
In [63]: next(gen)
In [50]: next(s)
Out[63]: 1
Out[50]: 2
In [64]: next(gen)
In [51]: a = {"sub": "ds"}
a Out[64]: 4

Out[51]: {'sub': 'ds'} In [65]: next(gen)

In [52]: d = iter(a) Out[65]: 9

In [53]: next(d) In [66]: next(gen)

Out[53]: 'sub' Out[66]: 16

In [55]: s = "Ajay" In [67]: next(gen)


for i in s:
print(i) ---------------------------------------------------------------------------
StopIteration Traceback (most recent call last)
A Cell In[67], line 1
j ----> 1 next(gen)
a
y StopIteration:

In [56]: #generator functions In [68]: range(1, 10)


#generator is a type of function which does not return a single value, instead returns an iterator object
Out[68]: range(1, 10)
In [57]: #regular function
def square_numbers(n): In [69]: for i in range(1, 10):
result = [] print(i)
for i in range(n):
result.append(i ** 2) 1
return result 2
square_numbers(5) 3
4
Out[57]: [0, 1, 4, 9, 16] 5
6
In [58]: def square_numbers_generator(n): 7
for i in range(n): 8
yield i ** 2 9

In [89]: #fibonacci series 0, 1, 1, 2, 3, 5, 8, 13 ....


In [60]: gen = square_numbers_generator(5)
def fib(n):
In [61]: gen a = 0
b = 1
Out[61]: <generator object square_numbers_generator at 0x7ffa704321f0> for i in range(n): #if n=5, 0, 1, 2, 3, 4
yield a In [1]: #oops>> object oriented programming system
a,b = b, a+b a = 5

In [90]: f = fib(10000000) In [3]: print(type(a))

<class 'int'>
In [91]: next(f)
In [4]: s = "pwskills"
Out[91]: 0 print(type(s))

In [92]: next(f) <class 'str'>

In [5]: a =6
Out[92]: 1
a =8
a =10
In [93]: next(f)

In [7]: print("Ajay")
Out[93]: 1
Ajay
In [94]: next(f)
In [8]: print("Aj")
Out[94]: 2
Aj

In [95]: next(f) In [9]: class Car:#naming convention>> UpperCamelCase


pass
Out[95]: 3
In [10]: a = Car() #instance, object
In [96]: next(f)
In [12]: print(type(a))
Out[96]: 5
<class '__main__.Car'>
In [97]: next(f)
In [25]: class Car: #function/method of a car
Out[97]: 8 def accelerate(self):
print("car is accelerting")
In [98]: next(f)

Out[98]: 13 In [26]: a = Car()

In [99]: next(f) In [27]: a.accelerate()

car is accelerting
Out[99]: 21
In [28]: #self > a variable that represents instance of the class using which you can access st
In [ ]:
In [30]: # def f1():
# pass
# def b2():
# pass
# def d1():
# pass

In [31]: class Car: #function/method of a car


def accelerate(self): In [48]: class Listops:
print("car is accelerting")
def brake(self): l = [1, 2, 3, 4, 5]
print("car is stopping") def extract_even(self, l):
l1 = []
In [32]: a = Car() for i in l:
a.brake() if i % 2 ==0:
l1.append(i)
car is stopping return l1

In [33]: class Bank: def extract_odd(self, l):


def deposit(self, amount): l1 = []
print("I am trying to deposit some money") for i in l:
def withdraw(self, amount_withdraw): if i % 2 !=0:
print("I am trying to withdraw some money") l1.append(i)
return l1
In [34]: ajay = Bank()
In [49]: ops1 = Listops()
In [35]: ajay.deposit(1000)
In [50]: ops1.l
I am trying to deposit some money
Out[50]: [1, 2, 3, 4, 5]
In [36]: deposit()

--------------------------------------------------------------------------- In [51]: ops1.extract_even(ops1.l)


NameError Traceback (most recent call last)
Cell In[36], line 1 Out[51]: [2, 4]
----> 1 deposit()
In [52]: ops2 = Listops()
NameError: name 'deposit' is not defined ops2.extract_even(ops2.l)

In [42]: class Bank: Out[52]: [2, 4]


amount = 1000
def deposit(self, amount):
In [54]: a =4
print("I am trying to deposit some money")
b=3
def withdraw(self, amount_withdraw):
print("I am trying to withdraw some money")
In [55]: a
In [43]: ajay = Bank()
Out[55]: 4

In [45]: ajay.deposit(1000)
In [56]: b
I am trying to deposit some money
Out[56]: 3
In [46]: ajay.amount
In [76]: class Listops:
Out[46]: 1000
def __init__(self, l):
In [47]: a =3 self.l = l
a= 3
a =8 def extract_even(self):
a=10 l = self.l
l1 = []
for i in l: In [90]: obj1.l
if i % 2 ==0:
l1.append(i) Out[90]: [1, 2, 3, 4, 5]
return l1
In [91]: class Book:
def extract_odd(self):
l=self.l def __init__(self, name, author, title):
l1 = [] self.name_of_book = name
for i in l: self.book_author = author
if i % 2 !=0: self.title_name = title
l1.append(i)
return l1 def extract_details_name_title(self):
print(self.name_of_book, self.title_name)
In [77]: obj1 = Listops([1, 2, 3, 4, 5])
def extract_details_name_author(self):
In [79]: obj1.l print(self.name_of_book, self.book_author)

Out[79]: [1, 2, 3, 4, 5]
In [92]: student1 = Book("ML", "MURPHY", "Linear Regression")
In [74]: obj1.l
In [93]: student1.extract_details_name_title()
Out[74]: [1, 2, 3, 4, 5]
ML Linear Regression

In [75]: obj2 = Listops([1, 8, 3, 4, 10]) In [94]: student2 = Book("DL", "abc", "CNN")


obj2.extract_even()

In [95]: student2.extract_details_name_author()
Out[75]: [8, 4, 10]
DL abc
In [88]: class Listops:
In [97]: student2.name_of_book
def __init__(self, l):
self.l = l Out[97]: 'DL'

def extract_even(self): In [100… class Book:


l = self.l
l1 = [] def __init__(self):
for i in l: self.name_of_book = "DSA"
if i % 2 ==0: self.book_author = "Cormen"
l1.append(i) self.title_name ="Stacks"
return l1
def extract_details_name_title(self):
def extract_odd(self): print(self.name_of_book, self.title_name)
l=self.l
l1 = [] def extract_details_name_author(self):
for i in l: print(self.name_of_book, self.book_author)
if i % 2 !=0:
l1.append(i)
In [101… student1 = Book()
return l1
student1.extract_details_name_author()

In [89]: obj1 = Listops([1, 2, 3, 4, 5]) DSA Cormen

In [103… student2 = Book()


student2.extract_details_name_author() In [1]: #inheritance >> refers to process of child class recieveing the properties of parent c
#Syntax
DSA Cormen # class BaseClass:
# #body of base class
In [104… class Book:
# class DerivedClass(BaseClass):
# #body of derived class
def __init__(self, name, author, title):
self.name_of_book = name
self.book_author = author In [2]: #single inheriatnce >> when a class has only one parent class
self.title_name = title

def extract_details_name_title(self):
print(self.name_of_book, self.title_name)

def extract_details_name_author(self):
print(self.name_of_book, self.book_author)

In [106… student1 = Book("ML", "MURPHY", "Linear Regression")


student1.extract_details_name_author()

ML MURPHY

In [ ]:

In [3]: class Father:


def father_property(self):
print("This is father property")

In [4]: class Son(Father):


def job(self):
print("Son has also a job")

In [5]: child_obj = Son()

In [7]: child_obj.job()

Son has also a job

In [8]: child_obj.father_property()

This is father property

In [9]: father_obj = Father()

In [11]: father_obj.father_property()

This is father property

In [12]: #parent class will not have access to the property of child class but child class will

In [13]: class Fruit:


def fruit_info(self):
print("Inside Parent class")
class Apple(Fruit):
def apple_info(self):
print("inside the child class")

In [14]: obj = Apple()

In [15]: obj.apple_info()

inside the child class

In [16]: obj.fruit_info()

Inside Parent class

In [17]: class Fruit:


def fruit_info(self):
print("Inside Parent class")
class Apple(Fruit):
def fruit_info(self): In [22]: class GrandFather:
print("Inside Child class") def prop_grand_father(self):
def apple_info(self): print("I am your grandfather")
print("inside the child class")
In [23]: class Father(GrandFather):
In [18]: apple = Apple() def prop_father(self):
print("I am your father and having property of mine and your grandfather as we
In [19]: apple.apple_info()
In [25]: class Son(Father):
inside the child class def prop_son(self):
print("I am son and having property of both my father and grand father"
In [20]: apple.fruit_info() #Method overriding>>child class is very powerful

Inside Child class In [26]: son = Son()

In [21]: #multi-level inheritence In [27]: son.prop_father()

I am your father and having property of mine and your grandfather as well

In [28]: son.prop_grand_father()

I am your grandfather

In [30]: class Vehicle:


def vehicle_info(self):
print("Inside Vehicle class")
class Car(Vehicle):
def car_info(self):
print("Inside Car class")
class SportsCar(Car):
def sports_car_info(self):
print("inside sports car class")

In [31]: sports_car = SportsCar()


In [32]: sports_car.sports_car_info() def method1(self):
print("method 1 of Parent class 1")
inside sports car class class ParentClass2:
def method2(self):
In [33]: sports_car.car_info()
print("method 2 of Parent class 2")
Inside Car class
In [42]: class ChildClass(ParentClass1, ParentClass2):
In [34]: sports_car.vehicle_info() def child_method(self):
print("child method")
Inside Vehicle class

In [35]: class Vehicle: In [43]: child = ChildClass()


def vehicle_info(self):
print("Inside Vehicle class") In [44]: child.method1()
class Car(Vehicle):
def car_info(self): method 1 of Parent class 1
print("Inside Car class")
class SportsCar(Car): In [45]: child.method2()
def vehicle_info(self): method 2 of Parent class 2
print("inside sports car class")
In [49]: class A:
In [36]: car = SportsCar() def method(self):
print("Method of class A")
In [37]: car.vehicle_info() #method overriding class B(A):
def method(self):
inside sports car class print("Method of class B")
class C(A):
In [38]: #Multiple inheritence >> one child class may inherit from multiple parent class def method(self):
print("method of class c")
class D(C, B):
pass

In [50]: d = D() #diamond problem

In [51]: d.method()

method of class c

In [52]: #HIERARCHICAL INHERITENCE

In [41]: class ParentClass1:


In [53]: class Vehicle:
def info(self):
print("This is vehicle")
class Car(Vehicle):
def car_info(self, name):
print("This is car info", name)
class Truck(Vehicle):
def truck_info(self, name): In [62]: class Vehicle:
print("Truck info", name) def vehicle_info(self):
print("Inside Vehicle class")
In [54]: obj1 = Car() class Car(Vehicle):
def car_info(self):
print("Inside car class")
In [55]: obj1.info() class Truck(Vehicle):
This is vehicle def truck_info(self, name):
print("Truck info", name)
In [57]: obj1.car_info("BMW")
class SportsCar(Car, Vehicle):
This is car info BMW def sports_info(self):
print("inside sports car class")
In [58]: obj2 = Truck()
In [63]: s_car = SportsCar()
In [59]: obj2.info()

This is vehicle In [64]: s_car.car_info()

Inside car class


In [60]: obj2.truck_info("Ford")

Truck info Ford In [65]: s_car.sports_info()

inside sports car class


In [61]: #Hybrid inheritance >> multiple types or a combination of different inheritence
In [66]: s_car.vehicle_info()

Inside Vehicle class

In [67]: #Abstraction >> concept of hiding the complex implementation


In [68]: import abc In [77]: rect = Rectange()
rect.calculate_area()
In [69]: class PwSkills :
Out[77]: 'Area of rectangle : length * breadth'
@abc.abstractmethod
def student_details(self): In [78]: c = Circle()
pass c.calculate_area()

@abc.abstractmethod Out[78]: 'Area of circle : pi r**2'


def student_assignment(self):
pass In [79]: class Shape:
@abc.abstractmethod
@abc.abstractmethod def calculate_area(self):
def student_marks(self): pass
pass
class Rectange(Shape):
In [70]: class DataScience(PwSkills): def calculate_area(self):
def student_details(self): print("Area of rectangle : length * breadth")
return "data science course student details" class Circle(Shape):
def student_marks(self): def calculate_area(self):
return "give ds course student's marks" print("Area of circle : pi r**2")

In [71]: class WebDev(PwSkills): In [80]: rect = Rectange()


def student_assignment(self): rect.calculate_area()
return "This will give student assignment of web dev class"
def student_marks(self): Area of rectangle : length * breadth
return "give web dev student's marks"
In [ ]:

In [72]: ds = DataScience()

In [73]: ds.student_details()

Out[73]: 'data science course student details'

In [74]: wb = WebDev()

In [75]: wb.student_marks()

Out[75]: "give web dev student's marks"

In [76]: class Shape:


@abc.abstractmethod
def calculate_area(self):
pass

class Rectange(Shape):
def calculate_area(self):
return "Area of rectangle : length * breadth"
class Circle(Shape):
def calculate_area(self):
return "Area of circle : pi r**2"
In [10]: #Polymorphism >> poly means many, morphism means forms/states In [20]: class Student:
#refers to an object taking several forms depending on data def student(self):
print("Welcome to PWskills class")
In [2]: len("Ajay") def student(self, name = ""):
print("Welcome to PWskills class", name)
Out[2]: 4 def student(self, name = "", course = ""):
print("Welcome to PWskills class", name, course)

In [4]: len([1, 2, 3, 4, 6, 7])


In [21]: stud = Student()
Out[4]: 6
In [22]: stud.student()
In [6]: def func(a, b): Welcome to PWskills class
return a+b
In [23]: stud.student("Ajay")
In [7]: func(3, 4)
Welcome to PWskills class Ajay
Out[7]: 7
In [24]: stud.student("Ajay", "DS")

In [8]: func("pw", "skills") Welcome to PWskills class Ajay DS

Out[8]: 'pwskills' In [25]: #method overloading>> student is taking different forms, the last method overwrites th

class Student:
In [9]: func([1, 2, 3], [4, 5, 6])
def student(self, name = "", course = ""):
print("Welcome to PWskills class", name, course)
Out[9]: [1, 2, 3, 4, 5, 6]

stud = Student()
In [11]: class teacher_lecture:
def lec_info(self):
In [26]: stud.student()
print("This is lec info with teacher perspective")
Welcome to PWskills class
In [13]: class student_lecture:
def lec_info(self): In [27]: stud.student("Ajay")
print("This is lec info with student perspective")
Welcome to PWskills class Ajay

In [14]: def parcer(class_obj): In [28]: stud.student("Ajay", "DS")


for i in class_obj:
i.lec_info() Welcome to PWskills class Ajay DS

In [29]: #Method Overriding >> method in parent class and child class with same signature, the
In [15]: obj1 = teacher_lecture()
obj2 = student_lecture()
In [30]: class Animal:
def sound(self):
In [16]: class_obj = [obj1, obj2]
print("Animal sound")
class Cat(Animal):
In [17]: parcer(class_obj) def sound(self):
print("Cat meows")
This is lec info with teacher perspective
This is lec info with student perspective
In [31]: cat = Cat()
In [18]: #polymorphism >> Method overloading, Method Overriding
In [32]: cat.sound()
Cat meows ---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
In [33]: #Encapsulation>> means hiding something Cell In[70], line 1
#Bundling of data and methods ----> 1 stud.__degree
#accsess modifier>> public, protected, private
AttributeError: 'Student' object has no attribute '__degree'
In [34]: #Public >> accessible from anywhere from outside/inside the class
In [ ]: stud._Student__degree
class Student:
def __init__(self, name, degree): In [71]: stud.show()
self.name = name
self.degree = degree name Ramesh degree Masters

In [79]: class Car:


In [36]: stud = Student("Ramesh", "Masters")
def __init__(self, year, make, speed, model):
self.__year = year
In [37]: stud.name self.__make = make
self.__speed = speed
Out[37]: 'Ramesh' self.__model = model

In [38]: stud.degree def set_speed(self, speed):


self.__speed = 0 if speed < 0 else speed
Out[38]: 'Masters'
def get_speed(self):
In [39]: stud.degree = "Phd" return self.__speed

In [40]: stud.degree In [80]: car = Car("1995", "Maruti", "80", "Brezza")

Out[40]: 'Phd' In [78]: car._Car__speed

In [67]: #private >> within the class only its accessible, use two __ to make private Out[78]: '80'

class Student: In [81]: car.get_speed()


def __init__(self, name, degree):
self.name = name Out[81]: '80'
self.__degree = degree
In [82]: car.set_speed(-1000)
def show(self):
#accessing the public and private data member
In [83]: car.get_speed()
print("name", self.name, 'degree', self.__degree)

Out[83]: 0
In [68]: stud = Student("Ramesh", "Masters")

In [84]: car.set_speed(100)
In [69]: stud.name

In [85]: car.get_speed()
Out[69]: 'Ramesh'

Out[85]: 100
In [70]: stud.__degree

In [86]: class Bank:

def __init__(self, balance):


self.__balance = balance print("name", self.name, "college", self._college_name)

def deposit(self, amount): In [99]: stud = Student("Ajay")


self.__balance = self.__balance + amount

In [100… stud.show()
def withdraw(self, amount):
if self.__balance >= amount: name Ajay college PWskills
self.__balance = self.__balance - amount
return True In [101… coll = College()
else:
return False
In [102… coll._college_name

def get_balance(self):
Out[102… 'PWskills'
return self.__balance

In [105… class College:


In [88]: acc = Bank(1000)
def __init__(self):
self._college_name = "PWskills"
In [89]: acc.get_balance()
class Student(College):
Out[89]: 1000 def __init__(self, name):
self.name = name
In [90]: acc.deposit(10000) super().__init__()

def show(self):
In [91]: acc.get_balance()
print("name", self.name, "college", self._college_name)
Out[91]: 11000
In [106… stud = Student("Ajay")
stud.show()
In [92]: acc.withdraw(10500)
name Ajay college PWskills
Out[92]: True
In [ ]:
In [93]: acc.get_balance()

Out[93]: 500

In [94]: acc.withdraw(1000)

Out[94]: False

In [98]: #protected>> within the class and its sub class protected member can be accessed, (_)

class College:
def __init__(self):
self._college_name = "PWskills"

class Student(College):
def __init__(self, name):
self.name = name
College.__init__(self)

def show(self):
In [6]: class Student: In [26]: stud.price_set = 1500
def __init__(self, name, price):
self.__name = name In [27]: stud.access_price
self.__price = price
Out[27]: 1500
In [7]: stud = Student("Ajay", 3000)
In [28]: class Student:
In [8]: stud.name #because its a private variable def __init__(self, name, price):
self.__name = name
--------------------------------------------------------------------------- self.__price = price
AttributeError Traceback (most recent call last)
Cell In[8], line 1 @property #it will make accesS_price as attribute of the class
----> 1 stud.name def access_price(self):
return self.__price
AttributeError: 'Student' object has no attribute 'name'
@access_price.setter
In [18]: class Student: def price_set(self, price_new):
def __init__(self, name, price): self.__price = price_new
self.__name = name
self.__price = price @access_price.deleter
def del_price(self):
@property #it will make accesS_price as attribute of the class del self.__price
def access_price(self):
return self.__price
In [29]: stud = Student("Ajay", 1000)

In [19]: stud = Student("Ajay", 2000)


In [30]: stud.access_price

In [20]: stud.access_price Out[30]: 1000

Out[20]: 2000
In [32]: stud.price_set = 2000

In [21]: class Student:


In [33]: stud.access_price
def __init__(self, name, price):
self.__name = name
Out[33]: 2000
self.__price = price

@property #it will make accesS_price as attribute of the class In [34]: del stud.del_price
def access_price(self):
return self.__price In [36]: stud.access_price

@access_price.setter ---------------------------------------------------------------------------
def price_set(self, price_new): AttributeError Traceback (most recent call last)
self.__price = price_new Cell In[36], line 1
----> 1 stud.access_price

In [22]: stud = Student("Ajay", 3000) Cell In[28], line 8, in Student.access_price(self)


6 @property #it will make accesS_price as attribute of the class
7 def access_price(self):
In [24]: stud.access_price ----> 8 return self.__price

Out[24]: 3000 AttributeError: 'Student' object has no attribute '_Student__price'


In [39]: class Circle: @radius.setter
def __init__(self, radius): def radius(self, value):
self.__radius = radius if value <= 0:
@property raise ValueError("Radius is not pos")
def radius(self): self.__radius =value
return self.__radius @radius,
def area(self):
In [40]: c = Circle(5) return 3.14 * self.__radius * self.__radius

In [41]: c.radius

Out[41]: 5

In [42]: class Circle:


def __init__(self, radius):
self.__radius = radius
@property
def radius(self):
return self.__radius
@radius.setter
def radius(self, value):
if value <= 0:
raise ValueError("Radius is not pos")
self.__radius =value
def area(self):
return 3.14 * self.__radius * self.__radius

In [44]: c = Circle(5)

In [45]: c.radius

Out[45]: 5

In [46]: c.radius = 10

In [47]: c.radius

Out[47]: 10

In [49]: c.radius = 10

In [50]: c.area()

Out[50]: 314.0

In [ ]: class Circle:
def __init__(self, radius):
self.__radius = radius
@property
def radius(self):
return self.__radius
In [1]: #dunder/special/magic Out[4]: ['__add__',
'__class__',
In [2]: a = "PW" '__contains__',
b = "Skills" '__delattr__',
a + b '__dir__',
'__doc__',
Out[2]: 'PWSkills' '__eq__',
'__format__',
In [3]: a.__add__(b) '__ge__',
'__getattribute__',
Out[3]: 'PWSkills' '__getitem__',
'__getnewargs__',
'__gt__',
In [4]: dir(str)
'__hash__',
'__init__',
'__init_subclass__',
'__iter__',
'__le__',
'__len__',
'__lt__',
'__mod__',
'__mul__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__rmod__',
'__rmul__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'capitalize',
'casefold',
'center',
'count',
'encode',
'endswith',
'expandtabs',
'find',
'format',
'format_map',
'index',
'isalnum',
'isalpha',
'isascii',
'isdecimal',
'isdigit',
'isidentifier',
'islower',
'isnumeric',
'isprintable',
'isspace',
'istitle', Out[8]: ['__abs__',
'isupper', '__add__',
'join', '__and__',
'ljust', '__bool__',
'lower', '__ceil__',
'lstrip', '__class__',
'maketrans', '__delattr__',
'partition', '__dir__',
'removeprefix', '__divmod__',
'removesuffix', '__doc__',
'replace', '__eq__',
'rfind', '__float__',
'rindex', '__floor__',
'rjust', '__floordiv__',
'rpartition', '__format__',
'rsplit', '__ge__',
'rstrip', '__getattribute__',
'split', '__getnewargs__',
'splitlines', '__gt__',
'startswith', '__hash__',
'strip', '__index__',
'swapcase', '__init__',
'title', '__init_subclass__',
'translate', '__int__',
'upper', '__invert__',
'zfill'] '__le__',
'__lshift__',
In [5]: 3+5 '__lt__',
'__mod__',
Out[5]: 8 '__mul__',
'__ne__',
In [6]: a = 3 '__neg__',
b = 5 '__new__',
a+b '__or__',
'__pos__',
Out[6]: 8 '__pow__',
'__radd__',
'__rand__',
In [7]: a.__add__(b)
'__rdivmod__',
'__reduce__',
Out[7]: 8
'__reduce_ex__',
'__repr__',
In [8]: dir(int) '__rfloordiv__',
'__rlshift__',
'__rmod__',
'__rmul__',
'__ror__',
'__round__',
'__rpow__',
'__rrshift__',
'__rshift__',
'__rsub__',
'__rtruediv__',
'__rxor__',
'__setattr__', In [19]: print(Student())
'__sizeof__', This method overrides the print statement of object method
'__str__',
'__sub__', In [21]: #repr
'__subclasshook__',
'__truediv__', class MyClass:
'__trunc__', def __init__(self, x):
'__xor__', self.x = x
'as_integer_ratio', def __repr__(self):
'bit_count', return f"MyClass({self.x})"
'bit_length',
'conjugate',
In [22]: obj = MyClass(2)
'denominator',
'from_bytes',
'imag', In [23]: print(repr(obj)) #retrun the string representation of object
'numerator',
MyClass(2)
'real',
'to_bytes']
In [24]: True == True
In [9]: class Student:
Out[24]: True
def __init__(self):
print("this is the first thing it will be executed once you make instance/object of the class"
In [26]: 3 == 3
In [11]: obj = Student()
Out[26]: True
this is the first thing it will be executed once you make instance/object of th
e class In [27]: a = 3
b = 3
In [12]: class Student: a.__eq__(b)
def __new__(cls):
print("This will be executed even before init") Out[27]: True
def __init__(self):
print("this is the first thing it will be executed once you make instance/object of the class"
In [28]: class Point:
def __init__(self, x, y):
In [13]: obj = Student() self.x = x
self.y = y
This will be executed even before init

In [14]: class Student: def __eq__(self, other):


def __init__(self): return self.x == other.x and self.y == other.y
self.phone = 99999999
In [31]: p1 = Point(1, 3)
In [16]: print(Student()) #hexadecimal representation p2 = Point(1, 2)

<__main__.Student object at 0x7f2417360c70> In [32]: print(p1 == p2)

In [17]: class Student: False


def __init__(self):
self.phone = 99999999 In [ ]:

def __str__(self): #__str__ will return a string represenation of


return "This method overrides the print statement of object method"
In [1]: #decorators >>allows to modify/extend the existing behaviour of functions or class without modifying it print("something is happening before func")
self.func()
In [4]: def my_decorator_func(): print("something is happening after func")
print("The lines being printed before the comp.")
print(1+11) In [18]: @MyDecorator #__call__ is a special method which is invoked when you call a decorator
print("The lines being printed after the comp.") def say_hello():
print("hello")
In [5]: my_decorator_func()
In [19]: say_hello()
The lines being printed before the comp.
12 something is happening before func
The lines being printed after the comp. hello
something is happening after func
In [6]: def my_decorator(func): #decorator func that takes another function as arguement
def wrapper(): #adds the functionality before and after calling func In [20]: #Built in decorators >> classmetod, staticmethod property
print("The lines being printed before the func.")
func() In [21]: #static method >> which can be called without createing an instance of class
print("The lines being printed after the func.")
return wrapper
In [25]: class Math:

In [7]: @my_decorator def add(self, x, y):


def say_hello(): return x+y
print("hello")
#when say_hello() is called, it is actually calling wrapper() which in turn calls say_hello()
In [26]: a = Math()#make object/instance

In [8]: say_hello()
In [27]: a.add(2, 3) #This was regular class
The lines being printed before the func.
hello Out[27]: 5
The lines being printed after the func.
In [28]: class Math:
In [12]: import time @staticmethod
def timer_decorator(func): def add(x, y):
def timer(): return x+y
start = time.time()
func()
In [29]: Math.add(2,3)
end = time.time()
print(end-start)
Out[29]: 5
return timer

In [30]: #class method >> takes class itself as first argument


In [15]: @timer_decorator
def func_test():
class Math:
print(1100*1000000)
@classmethod #takes reference to the class itself to modify and access class level
def add(cls, x, y):
In [16]: func_test() return cls.__name__, x+y # cls.__name__ >>Math
1100000000
4.792213439941406e-05 In [31]: Math.add(2, 3)

In [17]: class MyDecorator: Out[31]: ('Math', 5)


def __init__(self, func):
self.func = func In [36]: #property decorator >>it allows methods to be accessed as attribute
def __call__(self):
class Circle: In [1]: #class methods : bound to the class, can access and modify methods and attribute of al
def __init__(self, radius):
self.radius = radius In [2]: class Student:
def __init__(self, name): #method of an instance
def area(self): self.name = name
radius = self.radius
return 3.14 * radius ** 2
In [3]: obj = Student("Ajay")

In [35]: c = Circle(5)
In [4]: obj.name

In [ ]: c.radius Out[4]: 'Ajay'

In [5]: class Student:


def __init__(self, name): #instance
self.name = name

@classmethod#bound to the class


def student_details(cls, name):
return cls(name)

In [7]: obj1 = Student.student_details("Ajay")

In [9]: obj1.name

Out[9]: 'Ajay'

In [10]: class Student:


def __init__(self, name): #instance
self.name = name

@classmethod#bound to the class


def student_details(cls, name1):
return cls(name1)

In [11]: stud = Student.student_details("Sanjay")

In [12]: stud.name

Out[12]: 'Sanjay'

In [16]: class Student:

total_students = 0
def __init__(self, name): #instance
self.name = name
Student.total_students = Student.total_students + 1

@classmethod#bound to the class


def get_total_students(cls):
return cls.total_students
In [17]: Student.total_students In [32]: Student.get_total_students()

Out[17]: 0 ---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
In [18]: std1 = Student("Ajay") Cell In[32], line 1
----> 1 Student.get_total_students()

In [19]: std2 = Student("Bijay") AttributeError: type object 'Student' has no attribute 'get_total_students'

In [20]: Student.get_total_students() In [33]: #static method >> don't have access or modify class, work with the

Out[20]: 2 In [35]: class Calculator:

In [23]: #To make external class method to be part of the class @staticmethod
class Student: def add(x, y):
return x+y
total_students = 0
def __init__(self, name): #instance @staticmethod
self.name = name def subtract(x, y):
Student.total_students = Student.total_students + 1 return x-y

@classmethod#bound to the class In [36]: Calculator.add(5, 3)


def get_total_students(cls):
return cls.total_students Out[36]: 8

In [24]: def course_details(cls, course_name): In [37]: Calculator.subtract(5, 3)


print("The details of the course is :", course_name )
Out[37]: 2
In [25]: Student.course_details = classmethod(course_details) #adding the external class method
In [ ]:
In [26]: Student.course_details("Data Science")

The details of the course is : Data Science

In [27]: #delet any class method


del Student.course_details

In [28]: Student.course_details("Data Science")

---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[28], line 1
----> 1 Student.course_details("Data Science")

AttributeError: type object 'Student' has no attribute 'course_details'

In [30]: Student.get_total_students()

Out[30]: 0

In [31]: delattr(Student, "get_total_students")


In [18]: #r>> read mode\ In [28]: file = open("file.txt", "a")
#w >> write mode file.write("This is my fifth line.")
#a >> append mode file.close()
#r+>> both reading and writing
In [29]: file = open("file.txt", "r")
file = open("file.txt", "w")

In [32]: file.write("hello") #this will not be executed as it is opened in read mode


In [19]: file.write("Hello, this is my first line") #number below is no of bytes you have written
---------------------------------------------------------------------------
Out[19]: 28 UnsupportedOperation Traceback (most recent call last)
Cell In[32], line 1
In [20]: file.close() ----> 1 file.write("hello") #this will not be executed as it is opened in read
mode
In [11]: #file attributes
file UnsupportedOperation: not writable

In [33]: for i in file:


Out[11]: <_io.TextIOWrapper name='file.txt' mode='w' encoding='UTF-8'>
print(i)

In [12]: file.closed This is my first line

Out[12]: True This is my second line

In [13]: file.name This is my third line

Out[13]: 'file.txt' This is my fourth line

This is my fifth line.


In [14]: file.mode
In [35]: print(file.read()) #here the cursor or pointer is at last position
Out[14]: 'w'

In [36]: file.tell() #it tells the current position of the cursor


In [16]: file.write("This is my second line") #tHis will not be executed

--------------------------------------------------------------------------- Out[36]: 112


ValueError Traceback (most recent call last)
Cell In[16], line 1 In [37]: file.read()
----> 1 file.write("This is my second line") #tHis will not be executed
Out[37]: ''
ValueError: I/O operation on closed file.
In [38]: file.seek(0)
In [21]: file = open("file.txt", 'w')
Out[38]: 0
In [22]: file.write("This is my second line")
file.close() In [42]: f = open("file.txt", 'r')
print(f.readline())
In [27]: file = open("file.txt", "w") f.close()
file.write("This is my first line\n")
file.write("This is my second line\n") This is my first line
file.write("This is my third line\n")
file.write("This is my fourth line\n")
In [43]: file = open("file.txt", 'r')
file.close()
file.seek(0)
print(file.read()) In [59]: os.rmdir("feat")
file.close()

This is my first line In [60]: os.rmdir("test")


This is my second line
---------------------------------------------------------------------------
This is my third line
OSError Traceback (most recent call last)
This is my fourth line
Cell In[60], line 1
This is my fifth line.
----> 1 os.rmdir("test")
In [44]: f = open("file.txt", 'r')
print(f.readlines()) OSError: [Errno 39] Directory not empty: 'test'
f.close()
In [61]: import shutil
['This is my first line\n', 'This is my second line\n', 'This is my third line\ shutil.rmtree("1")
n', 'This is my fourth line\n', 'This is my fifth line.']
In [62]: os.getcwd()
In [45]: import os
Out[62]: '/home/jovyan/work'
In [46]: pwd
In [64]: f = open("/home/jovyan/work/test/test1/file_test.txt", "w")
Out[46]: '/home/jovyan/work'

In [65]: shutil.copy("/home/jovyan/work/test/test1/file_test.txt", "/home/jovyan/work")


In [47]: os.getcwd()
Out[65]: '/home/jovyan/work/file_test.txt'
Out[47]: '/home/jovyan/work'

In [67]: shutil.move("/home/jovyan/work/test/test1/file_test.txt", "/home/jovyan/work/test_move


In [48]: ls

File_handling_reading_and_writing.ipynb file.txt README.md sample-code.ipynb Out[67]: '/home/jovyan/work/test_move/file_test.txt'

In [49]: os.path.getsize("file.txt") In [66]: os.mkdir("test_move")

Out[49]: 112 In [69]: os.remove("file_test.txt")

In [54]: os.mkdir("test") In [70]: with open("file.txt", "r") as f:


line = f.readline()
In [55]: os.mkdir("test/test1") print(line)

This is my first line


In [56]: os.makedirs("1/2/3/4")

In [57]: os.listdir() In [ ]:

Out[57]: ['test',
'file.txt',
'.ipynb_checkpoints',
'1',
'sample-code.ipynb',
'.git',
'File_handling_reading_and_writing.ipynb',
'README.md']

In [58]: os.mkdir("feat")
In [1]: for i in range(10): In [1]: import logging
print("The current no is", i) logging.basicConfig(filename = "test_new1.log" , level = logging.DEBUG ,format

The current no is 0
The current no is 1 In [2]: logging.debug("debugging message")
The current no is 2
The current no is 3 In [3]: logging.info("info message")
The current no is 4
The current no is 5 In [4]: logging.shutdown()
The current no is 6
The current no is 7
In [1]: import logging
The current no is 8
logging.basicConfig(filename = "program.log" , level = logging.DEBUG ,format =
The current no is 9

In [3]: #logging>> keep track of In [2]: l = [1, "hello", [2, "world"], 3, ["python", 4]]
#logging module keep track of events in a software run
#write a prog to separate the integer and string in two list separfately
import logging
In [4]: l1_int = []
#logging supports different levels of logging which helps to catrgorize messages based on their severity l2_str = []

In [4]: logging.basicConfig(filename = "test.log", level = logging.INFO) for i in l:


logging.info(f"processing each element {i}")
In [5]: logging.info("This is my normal information about the software run")
if type(i) == list:
logging.error("This is the error msg")
for j in i:
logging.info(f"processing sublist element: {j}")
In [6]: logging.warning("This is my warning") if type(j) == int:
l1_int.append(j)
In [7]: logging.debug("This is my msg for debugging") elif type(i) == int:
l1_int.append(i)
In [8]: logging.critical("This is critical msg") else:
l2_str.append(i)
logging.info(f"The final result is: {l1_int}, {l2_str}")
In [9]: logging.shutdown()
logging.shutdown()

In [ ]: 1. DEBUG >> lowest level, debugging msg and variables


In [ ]:
2. INFO >> the things are working as expected
3. WARNING >> potential issues
4. ERROR >> serious problem
5. CRITICAL >> termination of progaram

In [1]: import logging


logging.basicConfig(filename = "test_new.log" , level = logging.DEBUG ,format =

In [2]: logging.debug("This msg is for debugging")

In [3]: logging.info("This is my info msg")

In [4]: logging.warning("This is my warning msg")

In [5]: logging.shutdown()
In [1]: text_content = """ data = {"name": "Ajay",
example 1 "Course": "DA",
example 2 "fee": 2900}
example 3
""" In [12]: type(data)

In [2]: with open("example.txt", "w") as file: Out[12]: dict


file.write(text_content)
In [15]: import json
In [3]: with open("example.txt", "r") as file: with open("json2.json", "w") as f:
data = file.read() json.dump(data, f)

print(data) In [16]: with open("json2.json", "r") as f:


example 1 data = json.load(f)
example 2
example 3 print(data)

{'name': 'Ajay', 'Course': 'DA', 'fee': 2900}

In [4]: #CSV>> comma separated values In [17]: with open("test_bin.bin", "wb") as f:


f.write(b"\x48\x65\x6c\x6c\x6f\x2c\x20\x57\x6f\x72\x6c\x64\x21")
data = [["Name", "course", "Fee"],
["Ajay", "DS", "1000"],
In [18]: with open("test_bin.bin", "rb") as f:
["Bijay", "ML", "2000"]]
print(f.read())

In [5]: data b'Hello, World!'

Out[5]: [['Name', 'course', 'Fee'], ['Ajay', 'DS', '1000'], ['Bijay', 'ML', '2000']] In [19]: #Buffered reading>> it allows the program to read the data in chunks
#BUFFERED writing
In [6]: for i in data:
print(i) In [20]: import io
with open("test_buf.txt", "wb") as f:
['Name', 'course', 'Fee'] file = io.BufferedWriter(f)
['Ajay', 'DS', '1000'] file.write(b"A computer is a machine that can be programmed to automatically carry
['Bijay', 'ML', '2000'] file.write(b"hello")
file.write(b"I am good")
In [8]: import csv file.flush()

with open("example_csv.csv", "w") as f:


In [22]: with open("test_buf.txt", "rb") as f:
w = csv.writer(f)
file = io.BufferedReader(f)
for i in data:
data = file.read(100) #100 bytes
w.writerow(i)
print(data)

In [9]: with open("example_csv.csv", "r") as f: b'A computer is a machine that can be programmed to automatically carry out seq
r = csv.reader(f) uences of arithmetic or'
for i in r:
print(i) In [ ]:

['Name', 'course', 'Fee']


['Ajay', 'DS', '1000']
['Bijay', 'ML', '2000']

In [11]: #Json >> javscript object notation


The string can not be converted to integer invalid literal for int() with ba
se 10: 'pwskills'
In [1]: 10/4
In [10]: import csv
Out[1]: 2.5

In [12]: try:
In [2]: 10/0 import pwskills
except ModuleNotFoundError as e:
--------------------------------------------------------------------------- print("the module not found", e)
ZeroDivisionError Traceback (most recent call last)
Cell In[2], line 1 the module not found No module named 'pwskills'
----> 1 10/0
In [13]: test()
ZeroDivisionError: division by zero
---------------------------------------------------------------------------
In [3]: try: NameError Traceback (most recent call last)
10/0 Cell In[13], line 1
except Exception as e: ----> 1 test()
print(e)
NameError: name 'test' is not defined
division by zero
In [14]: try:
In [5]: try: test()
10/0 except NameError as e:
except ZeroDivisionError as e: print(e)
print("Here I am handling the zero diviosion error", e)
name 'test' is not defined
Here I am handling the zero diviosion error division by zero
In [15]: d = {"name": "Ajay", "class":"ds"}
In [6]: # this is not best practice, always go for specific exception
# try:
In [16]: d["name"]
# 10/0
# except:
Out[16]: 'Ajay'
# print("This is some error")

This is some error In [17]: d["fee"]

In [7]: int("pwskills") ---------------------------------------------------------------------------


KeyError Traceback (most recent call last)
--------------------------------------------------------------------------- Cell In[17], line 1
ValueError Traceback (most recent call last) ----> 1 d["fee"]
Cell In[7], line 1
----> 1 int("pwskills") KeyError: 'fee'

ValueError: invalid literal for int() with base 10: 'pwskills' In [19]: try:
d = {"name": "Ajay", "class":"ds"}
In [8]: try: d["fee"]
int("pwskills") except KeyError as e:
except ValueError as e: print("The key is not found", e)
print("The string can not be converted to integer", e)
The key is not found 'fee'
The string can not be converted to integer invalid literal for int() with ba
se 10: 'pwskills' In [22]: try:
l = [1, 2, 3]
In [9]: try: l[4]
int("pwskills") except IndexError as e:
except (ValueError, TypeError) as e: print(e)
print("The string can not be converted to integer", e)
list index out of range except FileNotFoundError as e:
print("My file not found", e)
In [25]: try:
f = open("example1.txt", "r") My file not found [Errno 2] No such file or directory: 'example1.txt'
f.read()
except FileNotFoundError as e: In [7]: #give proper documentation, proiper comments
print("My file not found,", e)
"""
My file not found, [Errno 2] No such file or directory: 'example1.txt' This is my documentation
"""
In [26]: try:
f = open("example1.txt", "r") Out[7]: '\nThis is my documentation\n'
f.read()
except Exception as e: In [ ]: #always cleanup all the resources
print("first msg", e)
except FileNotFoundError as e: This notebook was converted with convert.ploomber.io
print("My file not found", e)

first msg [Errno 2] No such file or directory: 'example1.txt'

In [27]: #always try to log


import logging
logging.basicConfig(filename = "program.log", level = logging.DEBUG)
try:
f = open("example1.txt", "r")
f.read()
except FileNotFoundError as e:
logging.error(f"This is my error {e}")

In [1]: #always try to log


import logging
logging.basicConfig(filename = "program1.log", level = logging.DEBUG)
try:
10/0
except ZeroDivisionError as e:
logging.error(f"This is my zero divison {e}")

In [3]: def test(file):


try:
f = open(file, "r")
f.read()
except FileNotFoundError as e:
print(f"This is my error {e}")

In [4]: test("example1.txt")

This is my error [Errno 2] No such file or directory: 'example1.txt'

In [6]: #dont try to use unnecessary exception/multiple exception

try:
f = open("example1.txt", "r")
f.read()
except ZeroDivisionError as e:
print("first msg", e)
do something
sleep for 1 sec
In [1]: ## A process is an instance of a computer program done with sleeping
#executable program, data, execution context do something
#processor parallely>> multiprocessing sleep for 1 sec
#muultiple threads in processor/core >> multi threading done with sleeping
do something
In [4]: import time sleep for 1 sec
start = time.perf_counter() done with sleeping
do something
def test_func(): sleep for 1 sec
print("do something") done with sleeping
print("sleep for 1 sec") The program finished in 4.01 seconds.
time.sleep(1)
print("done with sleeping") In [11]: import time
import threading
test_func() start = time.perf_counter()
end = time.perf_counter()
def test_func():
print("do something")
print(f"The program finished in {round(end-start, 2)} seconds.") print("sleep for 1 sec")
time.sleep(1)
do something print("done with sleeping")
sleep for 1 sec
done with sleeping t1 = threading.Thread(target = test_func)
The program finished in 1.0 seconds. t2 = threading.Thread(target = test_func)

In [6]: import time t1.start() #to start the thread


start = time.perf_counter() t2.start()

def test_func(): t1.join() #in order to first execute the threads and then the execition of m
print("do something") t2.join()
print("sleep for 1 sec")
time.sleep(1)
print("done with sleeping") end = time.perf_counter()

test_func()
test_func() print(f"The program finished in {round(end-start, 2)} seconds.")
test_func()
test_func() do something
end = time.perf_counter() sleep for 1 sec
do something
sleep for 1 sec
print(f"The program finished in {round(end-start, 2)} seconds.") done with sleepingdone with sleeping

The program finished in 1.0 seconds.

In [12]: import time


import threading
start = time.perf_counter()

def test_func():
print("do something")
print("sleep for 1 sec")
time.sleep(1)
print("done with sleeping")
time.sleep(args)
threads = [] print("done with sleeping")
for i in range(10):
t = threading.Thread(target = test_func) threads = []
t.start() for i in range(10):
threads.append(t) t = threading.Thread(target = test_func, args = [2])
t.start()
for thread in threads: threads.append(t)
thread.join()
for thread in threads:
thread.join()

end = time.perf_counter()

end = time.perf_counter()
print(f"The program finished in {round(end-start, 2)} seconds.")

do something print(f"The program finished in {round(end-start, 2)} seconds.")


sleep for 1 sec
do something do something
sleep for 1 sec sleep for 2 sec
do something do something
sleep for 1 sec sleep for 2 sec
do something do something
sleep for 1 sec sleep for 2 sec
do something do something
sleep for 1 sec sleep for 2 sec
do something do something
sleep for 1 sec sleep for 2 sec
do something do something
sleep for 1 sec sleep for 2 sec
do something do something
sleep for 1 sec sleep for 2 sec
do something do something
sleep for 1 sec sleep for 2 sec
do something do something
sleep for 1 sec sleep for 2 sec
done with sleepingdone with sleeping do something
sleep for 2 sec
done with sleeping done with sleepingdone with sleeping
done with sleeping
done with sleeping done with sleeping
done with sleeping done with sleeping
done with sleeping done with sleeping
done with sleeping done with sleeping
done with sleeping done with sleeping
done with sleeping done with sleeping
The program finished in 1.01 seconds. done with sleeping
done with sleeping
In [13]: import time The program finished in 2.0 seconds.
import threading
start = time.perf_counter() In [ ]: #I/O bound task >> perfomance can be improved using multithreading >> readin

def test_func(args): In [14]: url_list = [


print("do something") 'https://raw.githubusercontent.com/dscape/spell/master/test/resources/bi
print(f"sleep for {args} sec") 'https://raw.githubusercontent.com/first20hours/google-10000-english/mas
'https://raw.githubusercontent.com/itsfoss/text-files/master/sherlock.tx
'https://raw.githubusercontent.com/itsfoss/text-files/master/sample_log_ with concurrent.futures.ThreadPoolExecutor() as executor:
] executor.map(file_download, url_list, data_list)

In [16]: import time


import threading
start = time.perf_counter() end = time.perf_counter()

url_list = [
'https://raw.githubusercontent.com/dscape/spell/master/test/resources/bi print(f"The program finished in {round(end-start, 2)} seconds.")
'https://raw.githubusercontent.com/first20hours/google-10000-english/mas The program finished in 0.3 seconds.
'https://raw.githubusercontent.com/itsfoss/text-files/master/sherlock.tx
'https://raw.githubusercontent.com/itsfoss/text-files/master/sample_log_ In [19]: #shared varaible across all the threads
]
start = time.perf_counter()
shared_counter = 0
data_list = ['data1.txt', 'data2.txt', 'data3.txt', 'data4.txt'] counter_lock = threading.Lock()

import urllib.request def increment_shared_counter(x):


def file_download(url, filename): global shared_counter
urllib.request.urlretrieve(url, filename) with counter_lock:
shared_counter = shared_counter+1
threads=[] print(f"Thread {x}: incremented shared counter to {shared_counter}")
for i in range(len(url_list)): time.sleep(1)
t = threading.Thread(target = file_download, args = (url_list[i], data_l
t.start() threads = [threading.Thread(target = increment_shared_counter, args=(i,)) fo
threads.append(t)
for thread in threads:
for thread in threads: thread.start()
thread.join()
for thread in threads:
thread.join()
end = time.perf_counter()
end = time.perf_counter()

print(f"The program finished in {round(end-start, 2)} seconds.")

The program finished in 0.8 seconds. print(f"The program finished in {round(end-start, 2)} seconds.")

Thread 1: incremented shared counter to 1


In [17]: import time Thread 2: incremented shared counter to 2
import concurrent.futures Thread 3: incremented shared counter to 3
start = time.perf_counter() Thread 4: incremented shared counter to 4
Thread 5: incremented shared counter to 5
url_list = [ Thread 6: incremented shared counter to 6
'https://raw.githubusercontent.com/dscape/spell/master/test/resources/bi The program finished in 6.01 seconds.
'https://raw.githubusercontent.com/first20hours/google-10000-english/mas
'https://raw.githubusercontent.com/itsfoss/text-files/master/sherlock.tx In [20]: start = time.perf_counter()
'https://raw.githubusercontent.com/itsfoss/text-files/master/sample_log_ shared_counter = 0
] counter_lock = threading.Lock()

def increment_shared_counter(x):
data_list = ['data1.txt', 'data2.txt', 'data3.txt', 'data4.txt'] global shared_counter
with counter_lock:
import urllib.request shared_counter = shared_counter+1
def file_download(url, filename): print(f"Thread {x}: incremented shared counter to {shared_counter}")
urllib.request.urlretrieve(url, filename) time.sleep(1)
with concurrent.futures.ThreadPoolExecutor() as executor:
thread_args =[1, 2, 3, 4, 5, 6] In [2]: import time
executor.map(increment_shared_counter, thread_args) start = time.perf_counter()

def test_func():
end = time.perf_counter() print("do something")
print("sleep for 1 sec")
time.sleep(1)
print(f"The program finished in {round(end-start, 2)} seconds.") print("done with sleeping")

Thread 1: incremented shared counter to 1 test_func()


Thread 2: incremented shared counter to 2 test_func()
Thread 3: incremented shared counter to 3 end = time.perf_counter()
Thread 4: incremented shared counter to 4
Thread 5: incremented shared counter to 5
Thread 6: incremented shared counter to 6 print(f"The program finished in {round(end-start, 2)} seconds.")
The program finished in 6.01 seconds.
do something
In [ ]: sleep for 1 sec
done with sleeping
This notebook was converted with convert.ploomber.io do something
sleep for 1 sec
done with sleeping
The program finished in 2.0 seconds.

In [3]: import multiprocessing

import time
start = time.perf_counter()

def test_func():
print("do something")
print("sleep for 1 sec")
time.sleep(1)
print("done with sleeping")

p1 = multiprocessing.Process(target = test_func)
p2 = multiprocessing.Process(target = test_func)

p1.start()
p2.start()

p1.join()
p2.join()

end = time.perf_counter()

print(f"The program finished in {round(end-start, 2)} seconds.")


do something do something
sleep for 1 sec sleep for 1 secdo something
do something
sleep for 1 sec do somethingsleep for 1 sec
done with sleeping
done with sleeping sleep for 1 secdo something
The program finished in 1.05 seconds.
sleep for 1 sec
In [4]: import multiprocessing do something
sleep for 1 sec
import time do something
start = time.perf_counter() sleep for 1 secdo somethingsleep for 1 sec

def test_func():
print("do something") do something
print("sleep for 1 sec") sleep for 1 sec
time.sleep(1) do something
print("done with sleeping") sleep for 1 sec
do something
processes = [] sleep for 1 sec
for i in range(10): done with sleeping
p=multiprocessing.Process(target = test_func) done with sleeping
p.start() done with sleeping
processes.append(p) done with sleeping
for process in processes: done with sleeping
process.join() done with sleeping
done with sleeping
end = time.perf_counter() done with sleeping
done with sleeping
done with sleeping
print(f"The program finished in {round(end-start, 2)} seconds.") The program finished in 1.08 seconds.

In [6]: import multiprocessing

import time
start = time.perf_counter()

def square(index, value):


value[index] = value[index] ** 2

arr = multiprocessing.Array('i', [1, 2, 5, 3, 4])

processes = []
for i in range(5):
p=multiprocessing.Process(target = square, args = (i, arr))
p.start()
processes.append(p)
for process in processes:
process.join()

print(list(arr))
end = time.perf_counter()

print(f"The program finished in {round(end-start, 2)} seconds.")


[1, 4, 25, 9, 16] Registrar: enroll Ajay
The program finished in 0.03 seconds. Registrar: enroll Bijay
Registrar: enroll Sanjay
In [8]: start = time.perf_counter() Registrar: enroll Rizwan
def square(no): Process Process-2:
result = no*no Traceback (most recent call last):
print(f"The square of {no} is {result}") File "/opt/conda/lib/python3.10/multiprocessing/process.py", line 314, in
_bootstrap
numbers = [2, 3, 4, 5, 6000] self.run()
File "/opt/conda/lib/python3.10/multiprocessing/process.py", line 108, in
run
with multiprocessing.Pool() as pool: self._target(*self._args, **self._kwargs)
pool.map(square, numbers) File "/tmp/ipykernel_4081/228598659.py", line 9, in register_students
enrollment_req = student_queue.get()
File "/opt/conda/lib/python3.10/multiprocessing/queues.py", line 103, in g
end = time.perf_counter() et
res = self._recv_bytes()
File "/opt/conda/lib/python3.10/multiprocessing/connection.py", line 221,
print(f"The program finished in {round(end-start, 2)} seconds.") in recv_bytes
The square of 2 is 4The square of 4 is 16The square of 3 is 9The square of 5 buf = self._recv_bytes(maxlength)
is 25The square of 6000 is 36000000 File "/opt/conda/lib/python3.10/multiprocessing/connection.py", line 419,
in _recv_bytes
buf = self._recv(4)
File "/opt/conda/lib/python3.10/multiprocessing/connection.py", line 384,
in _recv
The program finished in 0.36 seconds. chunk = read(handle, remaining)
KeyboardInterrupt
In [1]: import multiprocessing

def enroll_students(student_queue):
for student in ["Ajay", "Bijay", "Sanjay", "Rizwan"]:
student_queue.put(f"enroll {student}")

def register_students(student_queue):
while True:
enrollment_req = student_queue.get()
if enrollment_req is None:
break
print(f"Registrar: {enrollment_req}")

if True:
student_queue = multiprocessing.Queue()
enrollment_process = multiprocessing.Process(target = enroll_students, a
reg_process = multiprocessing.Process(target = register_students, args =

enrollment_process.start()
reg_process.start()

enrollment_process.join()
reg_process.join()
--------------------------------------------------------------------------- do somethingdo somethingdo somethingdo somethingdo somethingdo somethingdo s
KeyboardInterrupt Traceback (most recent call last) omethingdo somethingdo somethingdo something
Cell In[1], line 24
20 reg_process.start()
23 enrollment_process.join()
---> 24 reg_process.join()

File /opt/conda/lib/python3.10/multiprocessing/process.py:149, in BaseProces


s.join(self, timeout)
147 assert self._parent_pid == os.getpid(), 'can only join a child proce
ss'
148 assert self._popen is not None, 'can only join a started process' sleep for a secsleep for a secsleep for a secsleep for a secsleep for a secs
--> 149 res = self._popen.wait(timeout) leep for a secsleep for a secsleep for a secsleep for a secsleep for a sec
150 if res is not None:
151 _children.discard(self)

File /opt/conda/lib/python3.10/multiprocessing/popen_fork.py:43, in Popen.wa


it(self, timeout)
41 return None
42 # This shouldn't block if wait() returned successfully.
---> 43 return self.poll(os.WNOHANG if timeout == 0.0 else 0)
44 return self.returncode
done sleepingdone sleepingdone sleepingdone sleepingdone sleepingdone sleepi
File /opt/conda/lib/python3.10/multiprocessing/popen_fork.py:27, in Popen.po ng
ll(self, flag) done sleepingdone sleeping
25 if self.returncode is None:
26 try: done sleeping
---> 27 pid, sts = os.waitpid(self.pid, flag)
28 except OSError: done sleeping
29 # Child process not yet created. See #1731717
30 # e.errno == errno.ECHILD == 10
31 return None

KeyboardInterrupt: The program finished in 1.38 seconds

In [4]: import time In [ ]:


import concurrent.futures
This notebook was converted with convert.ploomber.io

def test_func(i):
print("do something")
print("sleep for a sec")
time.sleep(1)
print("done sleeping")

start = time.perf_counter()

# Use concurrent.futures process pool


with concurrent.futures.ProcessPoolExecutor() as executor:
executor.map(test_func, range(10))

end = time.perf_counter()

print(f"The program finished in {round(end - start, 2)} seconds")


In [1]: #numpy >> numerical python NumPy
#2005 by Travis Oliphant =====

In [2]: import numpy as np Provides


1. An array object of arbitrary homogeneous items
2. Fast mathematical operations over arrays
In [3]: np.__version__ 3. Linear Algebra, Fourier Transforms, Random Number Generation

Out[3]: '1.23.5' How to use the documentation


----------------------------
In [4]: print(np.__doc__) Documentation is available in two forms: docstrings provided
with the code, and a loose standing reference guide, available from
`the NumPy homepage <https://numpy.org>`_.

We recommend exploring the docstrings using


`IPython <https://ipython.org>`_, an advanced Python shell with
TAB-completion and introspection capabilities. See below for further
instructions.

The docstring examples assume that `numpy` has been imported as `np`::

>>> import numpy as np

Code snippets are indicated by three greater-than signs::

>>> x = 42
>>> x = x + 1

Use the built-in ``help`` function to view a function's docstring::

>>> help(np.sort)
... # doctest: +SKIP

For some objects, ``np.info(obj)`` may provide additional help. This is


particularly true if you see the line "Help on ufunc object:" at the top
of the help() page. Ufuncs are implemented in C, not Python, for speed.
The native Python help() does not know how to view their help, but our
np.info() function does.

To search for documents containing a keyword, do::

>>> np.lookfor('keyword')
... # doctest: +SKIP

General-purpose documents like a glossary and help on the basic concepts


of numpy are available under the ``doc`` sub-module::

>>> from numpy import doc


>>> help(doc)
... # doctest: +SKIP

Available subpackages
---------------------
lib
Basic functions used by several sub-packages. Out[8]: list
random
Core Random Tools
linalg In [9]: lis
Core Linear Algebra Tools
fft Out[9]: [1, 2, 3, 'pwskills', (3+5j), True, 1.2]
Core FFT routines
polynomial In [10]: #Numpy stores the data in an array
Polynomial tools #An array is a container used to store the data of same data type
testing
NumPy testing tools In [11]: #why numpy
distutils #Computation is fast>> due to array>>>continous memory location
Enhancements to distutils with support for #mathematical computation
Fortran compilers support and more.
In [12]: l = [1, 2, 3, 4, 5]
Utilities
---------
test In [13]: arr = np.array(l)
Run numpy unittests
show_config In [14]: arr
Show numpy build configuration
dual Out[14]: array([1, 2, 3, 4, 5])
Overwrite certain functions with high-performance SciPy tools.
Note: `numpy.dual` is deprecated. Use the functions from NumPy or Scipy
In [15]: l = [1, 2, 3, 4, 5.1]
directly instead of importing them from `numpy.dual`.
arr = np.array(l)
matlib
Make everything matrices.
__version__ In [16]: arr
NumPy version string
Out[16]: array([1. , 2. , 3. , 4. , 5.1])
Viewing documentation using IPython
----------------------------------- In [17]: l = [1, 2, 3, 4, 5.1, "Ajay"]
Start IPython with the NumPy profile (``ipython -p numpy``), which will arr = np.array(l)
import `numpy` under the alias `np`. Then, use the ``cpaste`` command to
paste examples into the shell. To see which functions are available in In [18]: arr
`numpy`, type ``np.<TAB>`` (where ``<TAB>`` refers to the TAB key), or use
``np.*cos*?<ENTER>`` (where ``<ENTER>`` refers to the ENTER key) to narrow Out[18]: array(['1', '2', '3', '4', '5.1', 'Ajay'], dtype='<U32')
down the list. To view the docstring for a function, use
``np.cos?<ENTER>`` (to view the docstring) and ``np.cos??<ENTER>`` (to view
In [19]: #arr stores homogenous data
the source code).

Copies vs. in-place operation In [20]: type(arr)


-----------------------------
Most of the functions in `numpy` return a copy of the array argument Out[20]: numpy.ndarray
(e.g., `np.sort`). In-place versions of these functions are often
available as array methods, i.e. ``x = np.array([1,2,3]); x.sort()``. In [21]: arr.ndim
Exceptions to this rule are documented.
Out[21]: 1

In [22]: arr1 = np.array([[1, 2, 3], [4, 5, 6]])


In [7]: lis = [1, 2, 3, "pwskills", 3+5j, True, 1.2]

In [23]: arr1
In [8]: type(lis)
Out[23]: array([[1, 2, 3], In [35]: np.asanyarray(mat) #Convert the input to an ndarray, but pass ndarray subclasses throu
[4, 5, 6]])
Out[35]: matrix([[1, 2, 3, 4]])
In [25]: arr1.ndim
In [36]: t = ([1, 2, 3], [4, 5, 6]) #tuple to array
Out[25]: 2
In [37]: type(t)
In [27]: mat = np.matrix([1, 2, 3, 4]) #matrix is a specialised array, 2 dimensional
Out[37]: tuple
In [28]: type(mat)
In [38]: np.array(t)
Out[28]: numpy.matrix
Out[38]: array([[1, 2, 3],
In [29]: np.matrix([[[1, 2], [3,4], [5,6]]]) [4, 5, 6]])

--------------------------------------------------------------------------- In [40]: l = [1, 2, 3, 4, 5]


ValueError Traceback (most recent call last) arr = np.array(l)
Cell In[29], line 1
----> 1 np.matrix([[[1, 2], [3,4], [5,6]]]) In [41]: arr

File /opt/conda/lib/python3.10/site-packages/numpy/matrixlib/defmatrix.py:149, Out[41]: array([1, 2, 3, 4, 5])


in matrix.__new__(subtype, data, dtype, copy)
147 shape = arr.shape In [43]: arr[0] = 500
148 if (ndim > 2):
--> 149 raise ValueError("matrix must be 2-dimensional")
150 elif ndim == 0: In [44]: arr
151 shape = (1, 1)
Out[44]: array([500, 2, 3, 4, 5])
ValueError: matrix must be 2-dimensional
In [45]: arr
In [30]: #more way to convert array
l = [1, 2, 3] Out[45]: array([500, 2, 3, 4, 5])
np.asarray(l)
In [46]: a = arr
Out[30]: array([1, 2, 3])

In [47]: a
In [31]: mat
Out[47]: array([500, 2, 3, 4, 5])
Out[31]: matrix([[1, 2, 3, 4]])

In [48]: arr[0] = 1000


In [32]: np.asarray(mat)

In [49]: a #change in array also lead to change in a >> shallow copy


Out[32]: array([[1, 2, 3, 4]])

Out[49]: array([1000, 2, 3, 4, 5])


In [33]: np.asanyarray([1, 2, 3])

In [50]: a = arr.copy()
Out[33]: array([1, 2, 3])

In [51]: a
In [34]: mat

Out[51]: array([1000, 2, 3, 4, 5])


Out[34]: matrix([[1, 2, 3, 4]])
In [52]: arr 0
1
Out[52]: array([1000, 2, 3, 4, 5]) 2
3
In [53]: arr[0] = 2000 4

In [67]: [i for i in range(5)]


In [54]: arr
Out[67]: [0, 1, 2, 3, 4]
Out[54]: array([2000, 2, 3, 4, 5])

In [69]: list((i for i in range(5)))


In [55]: a
Out[69]: [0, 1, 2, 3, 4]
Out[55]: array([1000, 2, 3, 4, 5])

In [71]: iterable = (i for i in range(5))


In [56]: #To create an array >> np.array, np.asarray, np.asanyarray, deep copy and shallow copy

In [72]: np.fromiter(iterable, int) #Create a new 1-dimensional array from an iterable object.
In [ ]: #multiple ways to generate array
Out[72]: array([0, 1, 2, 3, 4])
In [58]: arr1 = np.fromfunction(lambda i, j : i==j, (3,3)) #Construct an array by executing a function over each coordinate.
In [73]: np.fromstring('22 23 24', sep = " ") #values should be numerical
In [59]: arr1
Out[73]: array([22., 23., 24.])
Out[59]: array([[ True, False, False],
[False, True, False], In [78]: np.fromstring('22,23,24', sep = ",")
[False, False, True]])
Out[78]: array([22., 23., 24.])
In [60]: arr1.ndim

Out[60]: 2 In [77]: #for string character you have to use split


string = 'Ajay,Bijay,Sanjay'
string1 = string.split(',')
In [61]: arr1.shape #shape of array np.array(string1)

Out[61]: (3, 3) Out[77]: array(['Ajay', 'Bijay', 'Sanjay'], dtype='<U6')

In [63]: arr1.size #no of elements in array In [79]: list(range(10))

Out[63]: 9 Out[79]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

In [64]: arr2 = np.fromfunction(lambda i, j : i*j, (3,3)) In [80]: range(10)

In [65]: arr2 Out[80]: range(0, 10)

Out[65]: array([[0., 0., 0.], In [82]: #other methods of numpy>> to generate sequnce of nos
[0., 1., 2.], np.arange(1, 10, 0.1) #Return evenly spaced values within a given interval.
[0., 2., 4.]])

In [66]: for i in range(5):


print(i)
Out[82]: array([1. , 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2. , 2.1, 2.2, In [1]: import numpy as np
2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3. , 3.1, 3.2, 3.3, 3.4, 3.5,
3.6, 3.7, 3.8, 3.9, 4. , 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, In [2]: arr1 = np.random.randint(1, 3, (3,3))
4.9, 5. , 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6. , 6.1, arr2 = np.random.randint(1, 3, (3,3))
6.2, 6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7. , 7.1, 7.2, 7.3, 7.4,
7.5, 7.6, 7.7, 7.8, 7.9, 8. , 8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, In [3]: arr1
8.8, 8.9, 9. , 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 9.9])
Out[3]: array([[2, 1, 2],
In [83]: np.linspace(1, 5, 10)#Return evenly spaced numbers over a specified interval. [1, 2, 2],
#give me 10 numbers between 1 and 5 evenly spaced [1, 1, 2]])

Out[83]: array([1. , 1.44444444, 1.88888889, 2.33333333, 2.77777778, In [4]: arr1.flatten() #Return a copy of the array collapsed into one dimension.
3.22222222, 3.66666667, 4.11111111, 4.55555556, 5. ])
Out[4]: array([2, 1, 2, 1, 2, 2, 1, 1, 2])
In [ ]:

In [5]: #expand dimesnion


arr = np.array([1, 2, 3, 4])
arr

Out[5]: array([1, 2, 3, 4])

In [6]: arr.ndim

Out[6]: 1

In [13]: np.expand_dims(arr, axis = 0) #increases the dimension by 1 at provoided axis

Out[13]: array([[1, 2, 3, 4]])

In [10]: np.expand_dims(arr, axis = 1)

Out[10]: array([[1],
[2],
[3],
[4]])

In [12]: np.expand_dims(arr, axis = 1).ndim

Out[12]: 2

In [11]: arr

Out[11]: array([1, 2, 3, 4])

In [14]: arr = np.zeros((3, 4))

In [15]: arr.ndim

Out[15]: 2

In [16]: np.expand_dims(arr, axis=0)


Out[16]: array([[[0., 0., 0., 0.], In [28]: np.repeat(arr1, 2, axis=0)
[0., 0., 0., 0.],
[0., 0., 0., 0.]]]) Out[28]: array([[2, 1, 2],
[2, 1, 2],
In [17]: np.expand_dims(arr, axis=1) [1, 2, 2],
[1, 2, 2],
Out[17]: array([[[0., 0., 0., 0.]], [1, 1, 2],
[1, 1, 2]])
[[0., 0., 0., 0.]],
In [29]: np.repeat(arr1, 3, axis=0)
[[0., 0., 0., 0.]]])
Out[29]: array([[2, 1, 2],
In [18]: np.expand_dims(arr, axis=0).ndim [2, 1, 2],
[2, 1, 2],
Out[18]: 3 [1, 2, 2],
[1, 2, 2],
[1, 2, 2],
In [19]: a = np.array([[1], [2], [3]])
[1, 1, 2],
[1, 1, 2],
In [20]: a [1, 1, 2]])

Out[20]: array([[1], In [30]: np.repeat(arr1, 3, axis=1)


[2],
[3]]) Out[30]: array([[2, 2, 2, 1, 1, 1, 2, 2, 2],
[1, 1, 1, 2, 2, 2, 2, 2, 2],
In [21]: a.ndim [1, 1, 1, 1, 1, 1, 2, 2, 2]])

Out[21]: 2 In [31]: a

In [22]: np.squeeze(a) #Remove axes of length one from `a` Out[31]: array([[1],
[2],
Out[22]: array([1, 2, 3]) [3]])

In [33]: np.roll(a, -1)


In [23]: a
Out[33]: array([[2],
Out[23]: array([[1],
[3],
[2],
[1]])
[3]])
In [34]: np.roll(a, -2)
In [25]: np.repeat(a, 4)
Out[34]: array([[3],
Out[25]: array([1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3])
[1],
[2]])
In [26]: arr1
In [37]: c = np.array([[1,2], [3, 4], [5,6], [7,8]])
Out[26]: array([[2, 1, 2],
[1, 2, 2],
In [38]: c
[1, 1, 2]])
Out[38]: array([[1, 2],
In [27]: np.repeat(arr1, 2)
[3, 4],
[5, 6],
Out[27]: array([2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2])
[7, 8]])
In [40]: np.roll(c, 2) Out[48]: array([[2, 1, 2],
[1, 2, 2],
Out[40]: array([[7, 8], [1, 1, 2]])
[1, 2],
[3, 4], In [49]: ~arr1
[5, 6]])
Out[49]: array([[-3, -2, -3],
In [41]: np.roll(c, 2, axis=0) [-2, -3, -3],
[-2, -2, -3]])
Out[41]: array([[5, 6],
[7, 8], In [50]: #operations on numpy string array
[1, 2],
[3, 4]])
In [51]: d = np.array(["pw", "skills"])
In [42]: arr1
In [52]: d
Out[42]: array([[2, 1, 2],
[1, 2, 2], Out[52]: array(['pw', 'skills'], dtype='<U6')
[1, 1, 2]])
In [53]: np.char.upper(d)
In [43]: arr2
Out[53]: array(['PW', 'SKILLS'], dtype='<U6')
Out[43]: array([[1, 2, 2],
[2, 1, 2],
In [54]: np.char.capitalize(d)
[1, 1, 2]])
Out[54]: array(['Pw', 'Skills'], dtype='<U6')
In [44]: arr1 + arr2

Out[44]: array([[3, 3, 4], In [55]: #mathematical functions


[3, 3, 4],
[2, 2, 4]]) In [56]: arr1

In [45]: arr1-arr2 Out[56]: array([[2, 1, 2],


[1, 2, 2],
Out[45]: array([[ 1, -1, 0], [1, 1, 2]])
[-1, 1, 0],
[ 0, 0, 0]]) In [57]: np.sin(arr1)

In [46]: arr1 * arr2 Out[57]: array([[0.90929743, 0.84147098, 0.90929743],


[0.84147098, 0.90929743, 0.90929743],
Out[46]: array([[2, 2, 4], [0.84147098, 0.84147098, 0.90929743]])
[2, 2, 4],
[1, 1, 4]]) In [58]: np.cos(arr1)

In [47]: arr1 > arr2 Out[58]: array([[-0.41614684, 0.54030231, -0.41614684],


[ 0.54030231, -0.41614684, -0.41614684],
Out[47]: array([[ True, False, False], [ 0.54030231, 0.54030231, -0.41614684]])
[False, True, False],
[False, False, False]]) In [59]: np.tan(arr1)

In [48]: arr1 Out[59]: array([[-2.18503986, 1.55740772, -2.18503986],


[ 1.55740772, -2.18503986, -2.18503986],
[ 1.55740772, 1.55740772, -2.18503986]])
In [60]: np.log10(arr1) Out[71]: array([[2, 2, 4],
[2, 2, 4],
Out[60]: array([[0.30103, 0. , 0.30103], [1, 1, 4]])
[0. , 0.30103, 0.30103],
[0. , 0. , 0.30103]]) In [72]: np.multiply(arr1, arr2)

In [61]: np.exp(arr1) Out[72]: array([[2, 2, 4],


[2, 2, 4],
Out[61]: array([[7.3890561 , 2.71828183, 7.3890561 ], [1, 1, 4]])
[2.71828183, 7.3890561 , 7.3890561 ],
[2.71828183, 2.71828183, 7.3890561 ]]) In [73]: np.mod(arr1, arr2) #return elment wise remainder

In [62]: np.power(arr1, 3) Out[73]: array([[0, 1, 0],


[1, 0, 0],
Out[62]: array([[8, 1, 8], [0, 0, 0]])
[1, 8, 8],
[1, 1, 8]]) In [74]: np.sqrt(arr1)

In [63]: np.mean(arr1) Out[74]: array([[1.41421356, 1. , 1.41421356],


[1. , 1.41421356, 1.41421356],
Out[63]: 1.5555555555555556 [1. , 1. , 1.41421356]])

In [64]: np.max(arr1) In [75]: #sort search

Out[64]: 2 e = np.array([5, 6, 1, 2])

In [65]: np.min(arr1) In [76]: e

Out[65]: 1 Out[76]: array([5, 6, 1, 2])

In [66]: np.std(arr1) In [77]: np.sort(e)

Out[66]: 0.4969039949999533 Out[77]: array([1, 2, 5, 6])

In [67]: np.var(arr1) In [78]: f = np.array([5, 199, 200, 6, 7, 8])

Out[67]: 0.2469135802469136 In [79]: f

In [68]: arr1-arr2 Out[79]: array([ 5, 199, 200, 6, 7, 8])

Out[68]: array([[ 1, -1, 0], In [80]: np.sort(f)


[-1, 1, 0],
[ 0, 0, 0]]) Out[80]: array([ 5, 6, 7, 8, 199, 200])

In [70]: np.subtract(arr1, arr2)


In [81]: np.searchsorted(f, 170) #Find indices where elements should be inserted to maintain or
Out[70]: array([[ 1, -1, 0],
Out[81]: 6
[-1, 1, 0],
[ 0, 0, 0]])
In [83]: f = np.array([5, 199, 200, 6, 7, 0, 0, 0, 8])
In [71]: arr1 *arr2
In [84]: f
Out[84]: array([ 5, 199, 200, 6, 7, 0, 0, 0, 8]) Out[103… array([[4, 5, 3],
[6, 7, 4],
In [85]: np.count_nonzero(f) [6, 5, 8]])

Out[85]: 6 In [104… arr2

Out[104… array([[8, 1, 9],


In [88]: f[f > 0] [6, 5, 4],
[9, 7, 6]])
Out[88]: array([ 5, 199, 200, 6, 7, 8])
In [105… arr1 @ arr2
In [90]: np.where(f>0)
Out[105… array([[ 89, 50, 74],
Out[90]: (array([0, 1, 2, 3, 4, 8]),) [126, 69, 106],
[150, 87, 122]])
In [91]: np.extract(f>0, f)
In [106… arr1
Out[91]: array([ 5, 199, 200, 6, 7, 8])
Out[106… array([[4, 5, 3],
[6, 7, 4],
In [92]: f [6, 5, 8]])

Out[92]: array([ 5, 199, 200, 6, 7, 0, 0, 0, 8]) In [107… np.linalg.det(arr1)

In [93]: f.byteswap() Out[107… -12.000000000000016

Out[93]: array([ 360287970189639680, -4107282860161892352, -4035225266123964416, In [108… np.linalg.inv(arr1)


432345564227567616, 504403158265495552, 0,
0, 0, 576460752303423488]) Out[108… array([[-3. , 2.08333333, 0.08333333],
[ 2. , -1.16666667, -0.16666667],
In [94]: #matrix>> 2d array [ 1. , -0.83333333, 0.16666667]])

import numpy.matlib as nm In [109… a = np.array([[7, 5.3, -3], [3, -5, 2], [5, 3, -7]])

In [95]: nm.zeros(5) In [110… a

Out[95]: matrix([[0., 0., 0., 0., 0.]]) Out[110… array([[ 7. , 5.3, -3. ],
[ 3. , -5. , 2. ],
In [97]: nm.ones((3, 4)) [ 5. , 3. , -7. ]])

Out[97]: matrix([[1., 1., 1., 1.], In [111… b = np.array([16, 8, 0])


[1., 1., 1., 1.],
[1., 1., 1., 1.]]) In [112… b

In [102… #numpy linear algebra Out[112… array([16, 8, 0])

arr1 = np.random.randint(1, 10, (3, 3))


In [113… np.linalg.solve(a, b)
arr2 = np.random.randint(1, 10, (3, 3))

Out[113… array([2.59630607, 0.84432718, 2.21635884])


In [103… arr1

In [ ]:
In [1]: import numpy as np In [12]: arr.ndim

In [2]: a = np.zeros(5) #Return a new array of given shape and type, filled with zeros. Out[12]: 2

In [3]: a In [13]: #3 dimensional array


np.zeros(1)
Out[3]: array([0., 0., 0., 0., 0.])
Out[13]: array([0.])

In [4]: a.ndim
In [14]: np.zeros((2, 3))
Out[4]: 1
Out[14]: array([[0., 0., 0.],
[0., 0., 0.]])
In [5]: b = np.zeros((3, 4))
In [15]: arr = np.zeros((3, 4))
In [6]: b.ndim arr.ndim

Out[6]: 2 Out[15]: 2

In [7]: np.ones((3, 4)) In [16]: arr = np.zeros((1, 3, 4))


arr
Out[7]: array([[1., 1., 1., 1.],
[1., 1., 1., 1.], Out[16]: array([[[0., 0., 0., 0.],
[1., 1., 1., 1.]]) [0., 0., 0., 0.],
[0., 0., 0., 0.]]])
In [8]: np.twos(5) #doesnt exist in numpy
In [17]: arr.ndim
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last) Out[17]: 3
Cell In[8], line 1
----> 1 np.twos(5) #doesnt exist in numpy
In [18]: arr = np.zeros((1, 1, 3, 4))
arr
File /opt/conda/lib/python3.10/site-packages/numpy/__init__.py:311, in __getatt
r__(attr)
Out[18]: array([[[[0., 0., 0., 0.],
308 from .testing import Tester
[0., 0., 0., 0.],
309 return Tester
[0., 0., 0., 0.]]]])
--> 311 raise AttributeError("module {!r} has no attribute "
312 "{!r}".format(__name__, attr)) In [19]: arr.ndim

AttributeError: module 'numpy' has no attribute 'twos' Out[19]: 4

In [9]: np.array([[2, 2, 2], [2, 2, 2]])


In [20]: arr = np.zeros((1, 1, 1, 3, 4))
Out[9]: array([[2, 2, 2], arr
[2, 2, 2]])
Out[20]: array([[[[[0., 0., 0., 0.],
In [10]: arr = np.zeros((3, 4)) [0., 0., 0., 0.],
[0., 0., 0., 0.]]]]])

In [11]: arr
In [21]: arr.ndim

Out[11]: array([[0., 0., 0., 0.],


Out[21]: 5
[0., 0., 0., 0.],
[0., 0., 0., 0.]])
In [22]: arr In [33]: np.empty((3, 4)) #Return a new array of given shape and type, without initializing ent

Out[22]: array([[[[[0., 0., 0., 0.], Out[33]: array([[4., 4., 4., 4.],
[0., 0., 0., 0.], [4., 4., 4., 4.],
[0., 0., 0., 0.]]]]]) [4., 4., 4., 4.]])

In [23]: arr = np.ones((3, 4)) In [34]: #optional >> random module

In [24]: arr.ndim import random


random.choice((1, 2, 3, 4, 5))
Out[24]: 2
Out[34]: 2

In [25]: arr.shape
In [35]: random.choice('Ajay')
Out[25]: (3, 4)
Out[35]: 'a'

In [26]: arr
In [36]: random.randrange(1, 10)
Out[26]: array([[1., 1., 1., 1.],
[1., 1., 1., 1.], Out[36]: 7
[1., 1., 1., 1.]])
In [37]: random.random() # a random no is generated between 0(included) and 1 (excluded)
In [27]: arr + 5
Out[37]: 0.017769477320319083
Out[27]: array([[6., 6., 6., 6.],
[6., 6., 6., 6.], In [38]: lis = [1, 2, 3, 4, 5]
[6., 6., 6., 6.]]) lis

In [28]: a = arr * 5
Out[38]: [1, 2, 3, 4, 5]

In [29]: a
In [40]: random.shuffle(lis)

Out[29]: array([[5., 5., 5., 5.],


[5., 5., 5., 5.], In [41]: lis
[5., 5., 5., 5.]])
Out[41]: [2, 3, 1, 4, 5]
In [30]: a - 1
In [42]: random.uniform(7, 14)
Out[30]: array([[4., 4., 4., 4.],
[4., 4., 4., 4.], Out[42]: 12.573243031183921
[4., 4., 4., 4.]])
In [43]: #random numbers related concepts in numpy
In [31]: np.eye(3) #Return a 2-D array with ones on the diagonal and zeros elsewhere.
np.array([])

Out[31]: array([[1., 0., 0.],


Out[43]: array([], dtype=float64)
[0., 1., 0.],
[0., 0., 1.]])
In [44]: np.random.random_sample()
In [32]: np.eye(3, dtype = int)
Out[44]: 0.4880220291522446
Out[32]: array([[1, 0, 0],
[0, 1, 0], In [45]: np.random.random_sample((5, ))
[0, 0, 1]])
Out[45]: array([0.03546162, 0.96439444, 0.86559857, 0.45990473, 0.68239288]) Out[61]: array([[1, 3, 3, 4],
[4, 3, 3, 3],
In [46]: np.random.rand(1) [4, 4, 1, 4]])

Out[46]: array([0.89826893]) In [62]: arr.size

Out[62]: 12
In [48]: np.random.rand(2, 3)

Out[48]: array([[0.19956744, 0.85663567, 0.76798966], In [63]: #array size will not change, always resape parameter should be multiplication of origi
[0.01678481, 0.29287439, 0.5507118 ]])
In [64]: arr
In [49]: np.random.randn(2,3)
Out[64]: array([[1, 3, 3, 4],
Out[49]: array([[-0.85502332, -0.06881989, 0.76879661], [4, 3, 3, 3],
[ 0.64187717, 1.46547139, -1.07173591]]) [4, 4, 1, 4]])

In [51]: arr = np.random.randint(1, 5, size= (3, 4)) In [65]: arr.size

In [52]: arr.ndim Out[65]: 12

Out[52]: 2 In [69]: arr.reshape(12,1)

In [53]: arr.shape Out[69]: array([[1],


[3],
Out[53]: (3, 4) [3],
[4],
[4],
In [54]: arr.size
[3],
[3],
Out[54]: 12
[3],
[4],
In [55]: arr [4],
[1],
Out[55]: array([[1, 3, 3, 4], [4]])
[4, 3, 3, 3],
[4, 4, 1, 4]]) In [70]: arr.reshape(1, 12)

In [58]: #reshaping the array Out[70]: array([[1, 3, 3, 4, 4, 3, 3, 3, 4, 4, 1, 4]])

arr1 = arr.reshape(2, 6)
In [72]: arr.reshape(3, 3)

In [59]: arr1.shape ---------------------------------------------------------------------------


ValueError Traceback (most recent call last)
Out[59]: (2, 6) Cell In[72], line 1
----> 1 arr.reshape(3, 3)
In [60]: arr1.size
ValueError: cannot reshape array of size 12 into shape (3,3)
Out[60]: 12
In [73]: arr.reshape(3,4)

In [61]: arr
Out[73]: array([[1, 3, 3, 4],
[4, 3, 3, 3],
[4, 4, 1, 4]])
In [74]: #case when you dont know in reshape what should be the column count In [86]: arr.reshape(1, 2, 2, 3)

arr.reshape(4, -1) Out[86]: array([[[[1, 3, 3],


[4, 4, 3]],
Out[74]: array([[1, 3, 3],
[4, 4, 3], [[3, 3, 4],
[3, 3, 4], [4, 1, 4]]]])
[4, 1, 4]])
In [87]: arr.reshape(1, 2, 2, 3).ndim
In [75]: arr.reshape(2, -1)
Out[87]: 4
Out[75]: array([[1, 3, 3, 4, 4, 3],
[3, 3, 4, 4, 1, 4]]) In [88]: arr.reshape(4, 3, 1) #3 rows 1 column repeated 4 times in the third dimension

In [76]: arr.reshape(2, -100) Out[88]: array([[[1],


[3],
Out[76]: array([[1, 3, 3, 4, 4, 3], [3]],
[3, 3, 4, 4, 1, 4]])
[[4],
In [78]: arr1 = arr.reshape(-1, 3)#you know column count but no row count
[4],
[3]],
In [79]: arr1.size
[[3],
Out[79]: 12 [3],
[4]],
In [81]: arr.reshape(12, 1)
[[4],
Out[81]: array([[1], [1],
[3], [4]]])
[3],
[4], In [89]: #conditions on array
[4],
[3], arr1 = np.random.randint(1, 10, (5,6))
[3],
[3], In [90]: arr1
[4],
[4], Out[90]: array([[3, 8, 8, 1, 1, 7],
[1], [4, 4, 5, 5, 2, 5],
[4]]) [2, 2, 9, 9, 2, 4],
[8, 5, 4, 1, 4, 9],
In [82]: arr.reshape(12, 1).base #to see the original array [7, 8, 4, 9, 6, 9]])

Out[82]: array([[1, 3, 3, 4], In [91]: arr1.shape


[4, 3, 3, 3],
[4, 4, 1, 4]]) Out[91]: (5, 6)

In [85]: arr.reshape(2, 2, 3)
In [92]: arr1.ndim

Out[85]: array([[[1, 3, 3],


Out[92]: 2
[4, 4, 3]],

[[3, 3, 4], In [93]: arr1.size


[4, 1, 4]]])
Out[93]: 30 In [106… arr1[0:3, [0, 2]] #0to2nd row and 0th and 2nd column

Out[106… array([[3, 8],


In [94]: arr1 > 3
[4, 5],
[2, 9]])
Out[94]: array([[False, True, True, False, False, True],
[ True, True, True, True, False, True], In [107… #slicing on both rows and column
[False, False, True, True, False, True],
[ True, True, True, False, True, True],
[ True, True, True, True, True, True]]) In [110… arr1

In [95]: arr1[arr1> 3] Out[110… array([[3, 8, 8, 1, 1, 7],


[4, 4, 5, 5, 2, 5],
Out[95]: array([8, 8, 7, 4, 4, 5, 5, 5, 9, 9, 4, 8, 5, 4, 4, 9, 7, 8, 4, 9, 6, 9]) [2, 2, 9, 9, 2, 4],
[8, 5, 4, 1, 4, 9],
[7, 8, 4, 9, 6, 9]])
In [96]: arr1[arr1 < 3]
In [109… arr1[0:3, 1:3]
Out[96]: array([1, 1, 2, 2, 2, 2, 1])
Out[109… array([[8, 8],
In [97]: arr1 [4, 5],
[2, 9]])
Out[97]: array([[3, 8, 8, 1, 1, 7],
[4, 4, 5, 5, 2, 5], In [111… arr1[0:2, [0,1]]
[2, 2, 9, 9, 2, 4],
[8, 5, 4, 1, 4, 9], Out[111… array([[3, 8],
[7, 8, 4, 9, 6, 9]]) [4, 4]])

In [98]: #To access elements in the array In [112… arr1[0, [1, 3]]
arr1[0]
Out[112… array([8, 1])
Out[98]: array([3, 8, 8, 1, 1, 7])
In [113… arr1[2:4, [0, 3]]
In [99]: arr1[1]
Out[113… array([[2, 9],
Out[99]: array([4, 4, 5, 5, 2, 5]) [8, 1]])

In [100… arr1[1][0] In [114… arr1[2:5]

Out[100… 4 Out[114… array([[2, 2, 9, 9, 2, 4],


[8, 5, 4, 1, 4, 9],
[7, 8, 4, 9, 6, 9]])
In [101… arr1
In [115… arr1[2:5, 0:2]
Out[101… array([[3, 8, 8, 1, 1, 7],
[4, 4, 5, 5, 2, 5], Out[115… array([[2, 2],
[2, 2, 9, 9, 2, 4], [8, 5],
[8, 5, 4, 1, 4, 9], [7, 8]])
[7, 8, 4, 9, 6, 9]])
In [116… #mathematical operation on two arrays
In [103… arr1[0:3] #oth row, 1st row and 2nd row arr1 = np.random.randint(1, 3, (3, 3))
arr2 = np.random.randint(1, 3, (3, 3))
Out[103… array([[3, 8, 8, 1, 1, 7],
[4, 4, 5, 5, 2, 5],
In [117… arr1
[2, 2, 9, 9, 2, 4]])
Out[117… array([[1, 2, 1], /tmp/ipykernel_3900/824215542.py:1: RuntimeWarning: divide by zero encountered
[2, 1, 1], in divide
[2, 1, 1]]) arr1 / 0
Out[126… array([[inf, inf, inf],
In [118… arr2 [inf, inf, inf],
[inf, inf, inf]])
Out[118… array([[2, 1, 1],
[1, 2, 1], In [124… #matric multiplication>> different from index wise multiplication
[1, 1, 2]])
arr1 @ arr2 #1st way to do matrix multiplication
In [119… arr1+arr2 #indewise elment addition
Out[124… array([[5, 6, 5],
Out[119… array([[3, 3, 2], [6, 5, 5],
[3, 3, 2], [6, 5, 5]])
[3, 2, 3]])
In [125… np.dot(arr1, arr2) #ndst way to do matrix multiplication
In [120… arr1-arr2 #indexwise element substraction
Out[125… array([[5, 6, 5],
Out[120… array([[-1, 1, 0], [6, 5, 5],
[ 1, -1, 0], [6, 5, 5]])
[ 1, 0, -1]])
In [128… arr = np.zeros((3, 4))
In [121… arr1 * arr2 #index wise multiplication

Out[121… array([[2, 2, 1], In [129… #broadcasting


[2, 2, 1], arr
[2, 1, 2]])
Out[129… array([[0., 0., 0., 0.],
In [122… arr1, arr2 [0., 0., 0., 0.],
[0., 0., 0., 0.]])
Out[122… (array([[1, 2, 1],
[2, 1, 1], In [130… arr + 5
[2, 1, 1]]),
array([[2, 1, 1], Out[130… array([[5., 5., 5., 5.],
[1, 2, 1], [5., 5., 5., 5.],
[1, 1, 2]])) [5., 5., 5., 5.]])

In [123… arr1 / arr2 #index wise divison In [131… arr-5

Out[123… array([[0.5, 2. , 1. ], Out[131… array([[-5., -5., -5., -5.],


[2. , 0.5, 1. ], [-5., -5., -5., -5.],
[2. , 1. , 0.5]]) [-5., -5., -5., -5.]])

In [127… 4/0 In [132… arr

--------------------------------------------------------------------------- Out[132… array([[0., 0., 0., 0.],


ZeroDivisionError Traceback (most recent call last) [0., 0., 0., 0.],
Cell In[127], line 1 [0., 0., 0., 0.]])
----> 1 4/0
In [133… a = np.array([1, 2, 3, 4])
ZeroDivisionError: division by zero
In [134… a
In [126… arr1 / 0 #in python zero divion error will come, but in numpy no error
Out[134… array([1, 2, 3, 4])
In [135… a.ndim In [1]: # pandas is a fast, powerful, flexible and easy to use open source data analysis and m
# built on top of the Python programming language.
Out[135… 1
#2008, Mckinney
In [136… arr + a #very well with structured data

Out[136… array([[1., 2., 3., 4.], In [2]: import pandas as pd


[1., 2., 3., 4.],
[1., 2., 3., 4.]]) In [3]: df = pd.read_csv('services.csv') #Read a comma-separated values (csv) file into DataFr

In [141… a = np.array([[1, 2, 3, 4]])


In [4]: df

In [142… a

Out[142… array([[1, 2, 3, 4]])

In [143… #Transpose
a.T

Out[143… array([[1],
[2],
[3],
[4]])

In [145… arr1

Out[145… array([[1, 2, 1],


[2, 1, 1],
[2, 1, 1]])

In [146… arr1.T

Out[146… array([[1, 2, 2],


[2, 1, 1],
[1, 1, 1]])

In [ ]:
Out[4]: id location_id program_id accepted_payments alternate_name application_process id location_id program_id accepted_payments alternate_name application_proces

Walk in or apply by
0 1 1 NaN NaN NaN
Walk in. P
9 10 10 NaN NaN NaN California r

Apply by phone for an


1 2 2 NaN NaN NaN Walk in. P
appointment.
10 11 11 NaN NaN NaN California r
r

Phone for infor


2 3 3 NaN NaN NaN Walk in or apply b
(403-4300 Ext. 4322).
11 12 12 NaN NaN NaN phone, email o
webpage r

3 4 4 NaN NaN NaN Apply by phone. Walk in. P


12 13 13 NaN NaN NaN California r
r

Phone for Call for appointment


4 5 5 NaN NaN NaN 13 14 14 NaN NaN NaN Referral from huma
infor

Walk in or apply by
5 6 6 NaN NaN NaN phone for Walk in or thr
14 15 15 NaN NaN NaN
membership appli... other agency r

Apply by phone or be Walk in. W


6 7 7 NaN NaN NaN referred by a doctor, 15 16 16 NaN NaN NaN application
identification r

16 17 17 NaN NaN NaN Call for infor


7 8 8 NaN NaN NaN Apply by phone.

Call for scr


Walk in. P 17 18 18 NaN NaN NaN appointment. Medica
8 9 9 NaN NaN NaN residency in Califor
id location_id program_id accepted_payments alternate_name application_process Out[5]: 0 1 2 3 4 5

0 id location_id program_id accepted_payments alternate_name application_process

Walk in or apply by
Call for scr 1 1 1 NaN NaN NaN
phone.
18 19 19 NaN NaN NaN appointment
(650-347-3648).

19 20 20 NaN NaN NaN Apply by phone for


2 2 2 NaN NaN NaN
an appointment.

By phone during
20 21 21 NaN NaN NaN
business hours.
Phone for
information
3 3 3 NaN NaN NaN
(403-4300 Ext.
Cash, Check, Credit Fotos para Walk in or apply by 4322).
21 22 22 NaN
Card pasaportes phone or mail

4 4 4 NaN NaN NaN Apply by phone.


Walk in or apply by
22 23 22 NaN NaN NaN
phone or mail

23 rows × 22 columns
Phone for
5 5 5 NaN NaN NaN
information.
In [5]: df = pd.read_csv('services.csv', header = None) #internal integer indexes are provided by pandas
df

Walk in or apply by
phone for
6 6 6 NaN NaN NaN
membership
appli...

Apply by phone or
7 7 7 NaN NaN NaN be referred by a
doctor, soc...

8 8 8 NaN NaN NaN Apply by phone.

9 9 9 NaN NaN NaN Walk in. Proof of


0 1 2 3 4 5 0 1 2 3 4 5

residency in
Medical visits...
California requ...

Walk in. Proof of


Call for screening
10 10 10 NaN NaN NaN California
19 19 19 NaN NaN NaN appointment
residency to rece...
(650-347-3648).

Walk in. Proof of


11 11 11 NaN NaN NaN California 20 20 20 NaN NaN NaN Walk in.
residency require...

By phone during
21 21 21 NaN NaN NaN
business hours.
Walk in or apply by
12 12 12 NaN NaN NaN phone, email or
webpage re...
Cash, Check, Credit Fotos para Walk in or apply by
22 22 22 NaN
Card pasaportes phone or mail

Walk in. Proof of


13 13 13 NaN NaN NaN California
residency require... Walk in or apply by
23 23 22 NaN NaN NaN
phone or mail

Call for
appointment.
14 14 14 NaN NaN NaN
Referral from
24 rows × 22 columns
human serv...

In [7]: df = pd.read_csv('services.csv', skiprows = 2) #internal integer indexes are provided


df
Walk in or through
15 15 15 NaN NaN NaN other agency
referral.

Walk in. Written


16 16 16 NaN NaN NaN application,
identification r...

Call for
17 17 17 NaN NaN NaN
information.

Call for screening


18 18 18 NaN NaN NaN
appointment.
Out[7]:

Provides Provide
training and training an
Residents Residents
job placement job placemen
of San of San
Apply by to eligible Apply by to eligibl
Unnamed: Unnamed: Unnamed: Mateo Unnamed: Unnamed: Unnamed: Mateo
2 2.1 phone for an people age 55 2 2.1 phone for an people age 5
2 3 4 County 2 3 4 County
appointment. or over who appointment. or over wh
age 55 or age 55 or
meet certain meet certai
over over
qualifications. qualifications

Older speaking
Phone for
adults age supportive
information
0 3 3 NaN NaN NaN 55 or over counseling Walk in. Proof of Provides genera
(403-4300 Ext.
who can services to San California reading an
4322). 7 10 10 NaN NaN NaN NaN
benefit fr... residency to media materials
rece...
Parents,
children,
families supervised Walk in. Proof of Provides genera
1 4 4 NaN NaN NaN Apply by phone.
with visitation California
problems services and a ... 8 11 11 NaN NaN NaN NaN
residency materials
of c... require... including .
Low-
income Adults,
Provides fix Offers a
working Walk in or apply parents,
Phone for 8% short ter intergenerationa
2 5 5 NaN NaN NaN families 9 12 12 NaN NaN NaN by phone, email children in
information. literacy pr
with or webpage re... 1st-12th
eligible...
children grades i...
tran...

Walk in or apply Walk in. Proof of Provides genera


A multipurpose California
by phone for 10 13 13 NaN NaN NaN NaN
3 6 6 NaN NaN NaN Any age center offering a residency materials
membership
wide variety ... require... including .
appli...

Older Individuals
Call for Provides food
Apply by phone adults who or families
Rosener House is appointment. clothing, bu
or be referred have 11 14 14 NaN NaN NaN with low or
4 7 7 NaN NaN NaN a day center for Referral from tok
by a doctor, memory or no income
older adults... human serv...
soc... sensory ...
loss, ...
Adult
Senior alcoholic/ Provides a long
Walk in or
citizens Delivers a hot drug ter
12 15 15 NaN NaN NaN through other
age 60 or meal to the addictive
5 8 8 NaN NaN NaN Apply by phone. agency referral.
over, home of persons men and residential .
disabled women w...
indiv...

Walk in. Proof of Ethnic Walk in. Written emer


Provides general 13 16 16 NaN NaN NaN application, NaN assistanc
residency in minorities,
6 9 9 NaN NaN NaN reading material, identification r... including foo
California especially
including b...
requ... Spanish
Out[9]: program_id application_process

0 NaN Walk in or apply by phone.


Provides
training and 1 NaN Apply by phone for an appointment.
Residents
job placement
of San
Apply by to eligible 2 NaN Phone for information (403-4300 Ext. 4322).
Unnamed: Unnamed: Unnamed: Mateo
2 2.1 phone for an people age 55
2 3 4 County
appointment. or over who 3 NaN Apply by phone.
age 55 or
meet certain
over 4 NaN Phone for information.
qualifications.
5 NaN Walk in or apply by phone for membership appli...

6 NaN Apply by phone or be referred by a doctor, soc...

7 NaN Apply by phone.


Call for emergency food, 8 NaN Walk in. Proof of residency in California requ...
14 17 17 NaN NaN NaN NaN
information. clothing and
fur 9 NaN Walk in. Proof of California residency to rece...

10 NaN Walk in. Proof of California residency require...


Call for By appointment
screening only, P 11 NaN Walk in or apply by phone, email or webpage re...
15 18 18 NaN NaN NaN NaN
appointment. Smile pr
Medical visits... 12 NaN Walk in. Proof of California residency require...

13 NaN Call for appointment. Referral from human serv...


Call for Provides fr
screening medical and 14 NaN Walk in or through other agency referral.
16 19 19 NaN NaN NaN NaN
appointment dental car
(650-347-3648). 15 NaN Walk in. Written application, identification r...

16 NaN Call for information.


no unr
17 20 20 NaN NaN NaN Walk in. NaN fields for this 17 NaN Call for screening appointment. Medical visits...

18 NaN Call for screening appointment (650-347-3648).


By phone
just a test 19 NaN Walk in.
18 21 21 NaN NaN NaN during business NaN
hours.
20 NaN By phone during business hours.
Profit and
[NOTE THIS IS 21 NaN Walk in or apply by phone or mail
Cash, Walk in or apply nonprofit
Fotos para NOT A REAL
19 22 22 NaN Check, by phone or businesses,
pasaportes SERVICE--THIS IS 22 NaN Walk in or apply by phone or mail
Credit Card mail the public,
m...

Second In [105… df = pd.read_csv('services.csv')


[NOTE THIS IS
Walk in or apply service and df
NOT A REAL
20 23 22 NaN NaN NaN by phone or nonprofit
ORGANIZA
mail businesses,
the p...

21 rows × 22 columns

In [9]: df = pd.read_csv('services.csv', usecols = ['program_id', 'application_process'


df
Out[105… id location_id program_id accepted_payments alternate_name application_process id location_id program_id accepted_payments alternate_name application_proces

Walk in or apply by
0 1 1 NaN NaN NaN
Walk in. P
9 10 10 NaN NaN NaN California r

Apply by phone for an


1 2 2 NaN NaN NaN Walk in. P
appointment.
10 11 11 NaN NaN NaN California r
r

Phone for infor


2 3 3 NaN NaN NaN Walk in or apply b
(403-4300 Ext. 4322).
11 12 12 NaN NaN NaN phone, email o
webpage r

3 4 4 NaN NaN NaN Apply by phone. Walk in. P


12 13 13 NaN NaN NaN California r
r

Phone for Call for appointment


4 5 5 NaN NaN NaN 13 14 14 NaN NaN NaN Referral from huma
infor

Walk in or apply by
5 6 6 NaN NaN NaN phone for Walk in or thr
14 15 15 NaN NaN NaN
membership appli... other agency r

Apply by phone or be Walk in. W


6 7 7 NaN NaN NaN referred by a doctor, 15 16 16 NaN NaN NaN application
identification r

16 17 17 NaN NaN NaN Call for infor


7 8 8 NaN NaN NaN Apply by phone.

Call for scr


Walk in. P 17 18 18 NaN NaN NaN appointment. Medica
8 9 9 NaN NaN NaN residency in Califor
id location_id program_id accepted_payments alternate_name application_process Out[14]: 0 Walk in or apply by phone.
1 Apply by phone for an appointment.
2 Phone for information (403-4300 Ext. 4322).
3 Apply by phone.
4 Phone for information.
5 Walk in or apply by phone for membership appli...
Call for scr
6 Apply by phone or be referred by a doctor, soc...
18 19 19 NaN NaN NaN appointment
(650-347-3648). 7 Apply by phone.
8 Walk in. Proof of residency in California requ...
9 Walk in. Proof of California residency to rece...
10 Walk in. Proof of California residency require...
19 20 20 NaN NaN NaN 11 Walk in or apply by phone, email or webpage re...
12 Walk in. Proof of California residency require...
13 Call for appointment. Referral from human serv...
By phone during 14 Walk in or through other agency referral.
20 21 21 NaN NaN NaN 15 Walk in. Written application, identification r...
business hours.
16 Call for information.
17 Call for screening appointment. Medical visits...
18 Call for screening appointment (650-347-3648).
Cash, Check, Credit Fotos para Walk in or apply by
21 22 22 NaN 19 Walk in.
Card pasaportes phone or mail
20 By phone during business hours.
21 Walk in or apply by phone or mail
22 Walk in or apply by phone or mail
Name: application_process, dtype: object
Walk in or apply by
22 23 22 NaN NaN NaN
phone or mail In [15]: df['application_process']

Out[15]: 0 Walk in or apply by phone.


23 rows × 22 columns 1 Apply by phone for an appointment.
2 Phone for information (403-4300 Ext. 4322).
3 Apply by phone.
In [11]: #data structure>> series and dataframe 4 Phone for information.
#series >> 1 dimensional in nature 5 Walk in or apply by phone for membership appli...
#dataframe >> 2 dimensional in nature, multiple series constitutes to form a dataframe 6 Apply by phone or be referred by a doctor, soc...
7 Apply by phone.
8 Walk in. Proof of residency in California requ...
In [12]: type(df)
9 Walk in. Proof of California residency to rece...
10 Walk in. Proof of California residency require...
Out[12]: pandas.core.frame.DataFrame
11 Walk in or apply by phone, email or webpage re...
12 Walk in. Proof of California residency require...
In [14]: df.application_process 13 Call for appointment. Referral from human serv...
14 Walk in or through other agency referral.
15 Walk in. Written application, identification r...
16 Call for information.
17 Call for screening appointment. Medical visits...
18 Call for screening appointment (650-347-3648).
19 Walk in.
20 By phone during business hours.
21 Walk in or apply by phone or mail
22 Walk in or apply by phone or mail
Name: application_process, dtype: object

In [17]: type(df['application_process'])
Out[17]: pandas.core.series.Series In [37]: type(d)

Out[37]: pandas.core.series.Series
In [18]: type(df)

Out[18]: pandas.core.frame.DataFrame In [38]: d["Ajay"]

Out[38]: 100
In [19]: l = [1, 2, 3, 4]
s = pd.Series(l)
s In [39]: d.index

Out[19]: 0 1 Out[39]: Index(['Ajay', 'Bijay', 'Sanjay'], dtype='object')


1 2
2 3 In [40]: d["Ajay":"Sanjay"]
3 4
dtype: int64 Out[40]: Ajay 100
Bijay 200
In [20]: type(s) Sanjay 300
dtype: int64
Out[20]: pandas.core.series.Series
In [43]: d.reset_index(drop=True)
In [21]: s[0]
Out[43]: 0 100
Out[21]: 1 1 200
2 300
dtype: int64
In [22]: s[1]
In [45]: pd.DataFrame(d)
Out[22]: 2
Out[45]: 0
In [23]: s[3]
Ajay 100
Out[23]: 4
Bijay 200

In [24]: s[2:4] Sanjay 300

Out[24]: 2 3
3 4 In [46]: df
dtype: int64

In [25]: s[2:]

Out[25]: 2 3
3 4
dtype: int64

In [35]: d = pd.Series([100, 200, 300], index = ["Ajay", "Bijay", "Sanjay"])

In [36]: d

Out[36]: Ajay 100


Bijay 200
Sanjay 300
dtype: int64
Out[46]: id location_id program_id accepted_payments alternate_name application_process id location_id program_id accepted_payments alternate_name application_proces

Walk in or apply by
0 1 1 NaN NaN NaN
Walk in. P
9 10 10 NaN NaN NaN California r

Apply by phone for an


1 2 2 NaN NaN NaN Walk in. P
appointment.
10 11 11 NaN NaN NaN California r
r

Phone for infor


2 3 3 NaN NaN NaN Walk in or apply b
(403-4300 Ext. 4322).
11 12 12 NaN NaN NaN phone, email o
webpage r

3 4 4 NaN NaN NaN Apply by phone. Walk in. P


12 13 13 NaN NaN NaN California r
r

Phone for Call for appointment


4 5 5 NaN NaN NaN 13 14 14 NaN NaN NaN Referral from huma
infor

Walk in or apply by
5 6 6 NaN NaN NaN phone for Walk in or thr
14 15 15 NaN NaN NaN
membership appli... other agency r

Apply by phone or be Walk in. W


6 7 7 NaN NaN NaN referred by a doctor, 15 16 16 NaN NaN NaN application
identification r

16 17 17 NaN NaN NaN Call for infor


7 8 8 NaN NaN NaN Apply by phone.

Call for scr


Walk in. P 17 18 18 NaN NaN NaN appointment. Medica
8 9 9 NaN NaN NaN residency in Califor
id location_id program_id accepted_payments alternate_name application_process Out[49]: ['id',
'location_id',
'program_id',
'accepted_payments',
'alternate_name',
'application_process',
Call for scr
'audience',
18 19 19 NaN NaN NaN appointment
(650-347-3648). 'description',
'eligibility',
'email',
'fees',
19 20 20 NaN NaN NaN 'funding_sources',
'interpretation_services',
'keywords',
By phone during 'languages',
20 21 21 NaN NaN NaN 'name',
business hours.
'required_documents',
'service_areas',
'status',
Cash, Check, Credit Fotos para Walk in or apply by
21 22 22 NaN 'wait_time',
Card pasaportes phone or mail
'website',
'taxonomy_ids']

In [51]: df.head(5)
Walk in or apply by
22 23 22 NaN NaN NaN
phone or mail

23 rows × 22 columns

In [47]: df.shape

Out[47]: (23, 22)

In [48]: df.columns

Out[48]: Index(['id', 'location_id', 'program_id', 'accepted_payments',


'alternate_name', 'application_process', 'audience', 'description',
'eligibility', 'email', 'fees', 'funding_sources',
'interpretation_services', 'keywords', 'languages', 'name',
'required_documents', 'service_areas', 'status', 'wait_time', 'websit
e',
'taxonomy_ids'],
dtype='object')

In [49]: list(df.columns)
Out[51]: id location_id program_id accepted_payments alternate_name application_process Out[52]: id location_id program_id accepted_payments alternate_name application_process

Walk in or apply by Walk in or apply by


0 1 1 NaN NaN NaN 0 1 1 NaN NaN NaN

Apply by phone for an Apply by phone for an


1 2 2 NaN NaN NaN 1 2 2 NaN NaN NaN
appointment. appointment.

2 rows × 22 columns
Phone for infor
2 3 3 NaN NaN NaN
(403-4300 Ext. 4322).
In [53]: df.tail(5)

Out[53]: id location_id program_id accepted_payments alternate_name application_proces

3 4 4 NaN NaN NaN Apply by phone.


Call for scr
18 19 19 NaN NaN NaN appointmen
(650-347-3648)

Phone for
4 5 5 NaN NaN NaN
information. 19 20 20 NaN NaN NaN

5 rows × 22 columns By phone during


20 21 21 NaN NaN NaN
business hours

In [52]: df.head(2)

Cash, Check, Credit Fotos para Walk in or apply b


21 22 22 NaN
Card pasaportes phone or ma

Walk in or apply b
22 23 22 NaN NaN NaN
phone or ma

5 rows × 22 columns

In [55]: df.sample(1)
Out[55]: id location_id program_id accepted_payments alternate_name application_process Out[56]: id location_id program_id accepted_payments alternate_name application_proces

Walk in. P
Walk in or apply b
8 9 9 NaN NaN NaN residency in Califor 0 1 1 NaN NaN NaN

1 rows × 22 columns
Apply by phone for a
1 2 2 NaN NaN NaN
appointment
In [56]: df

Phone for infor


2 3 3 NaN NaN NaN
(403-4300 Ext. 4322)

3 4 4 NaN NaN NaN Apply by phone

Phone fo
4 5 5 NaN NaN NaN
infor

Walk in or apply b
5 6 6 NaN NaN NaN phone fo
membership appli..

Apply by phone or b
6 7 7 NaN NaN NaN referred by a doctor

7 8 8 NaN NaN NaN Apply by phone

Walk in. P
8 9 9 NaN NaN NaN residency in Califor
id location_id program_id accepted_payments alternate_name application_process id location_id program_id accepted_payments alternate_name application_proces

Walk in. P
Call for scr
9 10 10 NaN NaN NaN California r
18 19 19 NaN NaN NaN appointmen
(650-347-3648)

Walk in. P
10 11 11 NaN NaN NaN California r 19 20 20 NaN NaN NaN
r

By phone during
20 21 21 NaN NaN NaN
business hours
Walk in or apply by
11 12 12 NaN NaN NaN phone, email or
webpage r
Cash, Check, Credit Fotos para Walk in or apply b
21 22 22 NaN
Card pasaportes phone or ma

Walk in. P
12 13 13 NaN NaN NaN California r
r Walk in or apply b
22 23 22 NaN NaN NaN
phone or ma

Call for appointment.


13 14 14 NaN NaN NaN Referral from human 23 rows × 22 columns

In [57]: df.info()

Walk in or thr
14 15 15 NaN NaN NaN
other agency r

Walk in. W
15 16 16 NaN NaN NaN application,
identification r

16 17 17 NaN NaN NaN Call for infor

Call for scr


17 18 18 NaN NaN NaN appointment. Medical
<class 'pandas.core.frame.DataFrame'> Out[59]: id int64
RangeIndex: 23 entries, 0 to 22 location_id int64
Data columns (total 22 columns): program_id float64
# Column Non-Null Count Dtype accepted_payments object
--- ------ -------------- ----- alternate_name object
0 id 23 non-null int64 application_process object
1 location_id 23 non-null int64 audience object
2 program_id 0 non-null float64 description object
3 accepted_payments 1 non-null object eligibility object
4 alternate_name 1 non-null object email object
5 application_process 23 non-null object fees object
6 audience 14 non-null object funding_sources object
7 description 23 non-null object interpretation_services object
8 eligibility 21 non-null object keywords object
9 email 1 non-null object languages object
10 fees 21 non-null object name object
11 funding_sources 21 non-null object required_documents object
12 interpretation_services 1 non-null object service_areas object
13 keywords 21 non-null object status object
14 languages 1 non-null object wait_time object
15 name 23 non-null object website object
16 required_documents 1 non-null object taxonomy_ids object
17 service_areas 21 non-null object dtype: object
18 status 23 non-null object
19 wait_time 19 non-null object In [62]: df['id']
20 website 2 non-null object
21 taxonomy_ids 1 non-null object Out[62]: 0 1
dtypes: float64(1), int64(2), object(19) 1 2
memory usage: 4.1+ KB 2 3
3 4
In [59]: df.dtypes 4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
Name: id, dtype: int64

In [63]: df['application_process']
Out[63]: 0 Walk in or apply by phone. Out[66]: list[0 Walk in or apply by phone.
1 Apply by phone for an appointment. 1 Apply by phone for an appointment.
2 Phone for information (403-4300 Ext. 4322). 2 Phone for information (403-4300 Ext. 4322).
3 Apply by phone. 3 Apply by phone.
4 Phone for information. 4 Phone for information.
5 Walk in or apply by phone for membership appli... 5 Walk in or apply by phone for membership appli...
6 Apply by phone or be referred by a doctor, soc... 6 Apply by phone or be referred by a doctor, soc...
7 Apply by phone. 7 Apply by phone.
8 Walk in. Proof of residency in California requ... 8 Walk in. Proof of residency in California requ...
9 Walk in. Proof of California residency to rece... 9 Walk in. Proof of California residency to rece...
10 Walk in. Proof of California residency require... 10 Walk in. Proof of California residency require...
11 Walk in or apply by phone, email or webpage re... 11 Walk in or apply by phone, email or webpage re...
12 Walk in. Proof of California residency require... 12 Walk in. Proof of California residency require...
13 Call for appointment. Referral from human serv... 13 Call for appointment. Referral from human serv...
14 Walk in or through other agency referral. 14 Walk in or through other agency referral.
15 Walk in. Written application, identification r... 15 Walk in. Written application, identification r...
16 Call for information. 16 Call for information.
17 Call for screening appointment. Medical visits... 17 Call for screening appointment. Medical visits...
18 Call for screening appointment (650-347-3648). 18 Call for screening appointment (650-347-3648).
19 Walk in. 19 Walk in.
20 By phone during business hours. 20 By phone during business hours.
21 Walk in or apply by phone or mail 21 Walk in or apply by phone or mail
22 Walk in or apply by phone or mail 22 Walk in or apply by phone or mail
Name: application_process, dtype: object Name: application_process, dtype: object]

In [64]: type(df['application_process']) In [68]: #series to dataframe

Out[64]: pandas.core.series.Series s = pd.Series([2, 3, 4], index = [100, "Ajay", 2])


s
In [66]: list[df['application_process']]
Out[68]: 100 2
Ajay 3
2 4
dtype: int64

In [69]: d = pd.DataFrame(s)

In [70]: d

Out[70]: 0

100 2

Ajay 3

2 4

In [81]: d['new_column'] = "Bijay"

In [82]: d
Out[82]: 0 new column new_column In [91]: df

100 2 Bijay Bijay

Ajay 3 Bijay Bijay

2 4 Bijay Bijay

In [83]: d['new_column']

Out[83]: 100 Bijay


Ajay Bijay
2 Bijay
Name: new_column, dtype: object

In [85]: d.new_column

Out[85]: 100 Bijay


Ajay Bijay
2 Bijay
Name: new_column, dtype: object

In [87]: d.columns = ['id', 'name', 'new_name']

In [88]: d

Out[88]: id name new_name

100 2 Bijay Bijay

Ajay 3 Bijay Bijay

2 4 Bijay Bijay

In [89]: d.reset_index()

Out[89]: index id name new_name

0 100 2 Bijay Bijay

1 Ajay 3 Bijay Bijay

2 2 4 Bijay Bijay

In [90]: d.reset_index(drop=True)

Out[90]: id name new_name

0 2 Bijay Bijay

1 3 Bijay Bijay

2 4 Bijay Bijay
Out[91]: id location_id program_id accepted_payments alternate_name application_process id location_id program_id accepted_payments alternate_name application_proces

Walk in or apply by
0 1 1 NaN NaN NaN
Walk in. P
9 10 10 NaN NaN NaN California r

Apply by phone for an


1 2 2 NaN NaN NaN Walk in. P
appointment.
10 11 11 NaN NaN NaN California r
r

Phone for infor


2 3 3 NaN NaN NaN Walk in or apply b
(403-4300 Ext. 4322).
11 12 12 NaN NaN NaN phone, email o
webpage r

3 4 4 NaN NaN NaN Apply by phone. Walk in. P


12 13 13 NaN NaN NaN California r
r

Phone for Call for appointment


4 5 5 NaN NaN NaN 13 14 14 NaN NaN NaN Referral from huma
infor

Walk in or apply by
5 6 6 NaN NaN NaN phone for Walk in or thr
14 15 15 NaN NaN NaN
membership appli... other agency r

Apply by phone or be Walk in. W


6 7 7 NaN NaN NaN referred by a doctor, 15 16 16 NaN NaN NaN application
identification r

16 17 17 NaN NaN NaN Call for infor


7 8 8 NaN NaN NaN Apply by phone.

Call for scr


Walk in. P 17 18 18 NaN NaN NaN appointment. Medica
8 9 9 NaN NaN NaN residency in Califor
id location_id program_id accepted_payments alternate_name application_process Out[99]: name languages status

0 Fair Oaks Adult Activity Center NaN active

1 Second Career Employment Program NaN active

2 Senior Peer Counseling NaN active


Call for scr
18 19 19 NaN NaN NaN appointment 3 Family Visitation Center NaN active
(650-347-3648).
4 Economic Self-Sufficiency Program NaN active

5 Little House Recreational Activities NaN active


19 20 20 NaN NaN NaN
6 Rosener House Adult Day Services NaN active

7 Meals on Wheels - South County NaN active


By phone during
20 21 21 NaN NaN NaN 8 Fair Oaks Branch NaN active
business hours.
9 Main Library NaN active

Cash, Check, Credit Fotos para Walk in or apply by 10 Schaberg Branch NaN active
21 22 22 NaN
Card pasaportes phone or mail
11 Project Read NaN active

12 Redwood Shores Branch NaN active

13 Redwood City Corps NaN active


Walk in or apply by
22 23 22 NaN NaN NaN
phone or mail 14 Adult Rehabilitation Center NaN active

15 Sunnyvale Corps NaN active

23 rows × 22 columns 16 South San Francisco Citadel Corps NaN active

17 Project Smile NaN active


In [92]: df.columns 18 San Mateo Free Medical Clinic NaN active

Out[92]: Index(['id', 'location_id', 'program_id', 'accepted_payments', 19 Service with blank fields NaN defunct
'alternate_name', 'application_process', 'audience', 'description',
'eligibility', 'email', 'fees', 'funding_sources', 20 Service for Admin Test Location NaN inactive
'interpretation_services', 'keywords', 'languages', 'name', 21 Passport Photos Spanish active
'required_documents', 'service_areas', 'status', 'wait_time', 'websit
e', 22 Example Service Name NaN active
'taxonomy_ids'],
dtype='object')
In [103… df1 = pd.read_excel("LUSID Excel - Setting up your market data.xlsx")
In [99]: df_subset = df[['name', 'languages', 'status']]
df_subset In [104… df1
Out[104… Unnamed: Unnamed: Unnamed: Unnamed: Unnamed: Unnamed: Unnamed: Unnamed: Unnamed: Unnamed: Unnamed: Unnamed:
Unnamed: 5 Unnamed: 5
0 1 2 3 4 0 1 2 3 4

0 NaN NaN NaN NaN NaN NaN 16 NaN NaN NaN NaN NaN NaN

Datetimes This date


1 NaN NaN NaN NaN NaN
in LUSID has no 2019-04-10
17 NaN NaN NaN NaN
time 00:00:00
2 NaN NaN NaN NaN NaN NaN component

This sheet 18 NaN NaN NaN NaN NaN NaN


allows you
3 NaN NaN NaN to format NaN NaN
datetimes Specify
for... 19 NaN NaN NaN NaN time 13:30:45.550000
component
If you have
any
4 NaN NaN NaN questions NaN NaN 20 NaN NaN NaN NaN NaN NaN
please visit
our: Add to
your date
Getting and 2019-04-10
21 NaN NaN NaN NaN
5 NaN NaN NaN NaN Started NaN display the 13:30:45.550000
tutorials complete
date...
Knowledge
6 NaN NaN NaN NaN Base NaN 22 NaN NaN NaN NaN NaN NaN
articles
Although
or Contact the date
7 NaN NaN NaN NaN NaN
us can still 2019-04-10
23 NaN NaN NaN NaN
appears 13:30:45.550000
8 NaN NaN NaN NaN NaN NaN without
time
9 NaN NaN NaN NaN NaN NaN
24 NaN NaN NaN NaN NaN NaN
10 NaN NaN NaN NaN NaN NaN
Add an
LUSID hour to 2019-04-10
accepts 25 NaN NaN NaN NaN
your 14:30:45.550000
datetimes datetime
11 NaN NaN NaN NaN NaN
in any
recognised 26 NaN NaN NaN NaN NaN NaN
Exce...
Subtract a
12 NaN NaN NaN NaN NaN NaN minute 2019-04-10
27 NaN NaN NaN NaN
from your 14:29:45.550000
Excel datetime
formats to
13 NaN NaN NaN NaN NaN
show
datetime
In [107… df1.columns
14 NaN NaN NaN NaN NaN NaN
Out[107… Index(['Unnamed: 0', 'Unnamed: 1', 'Unnamed: 2', 'Unnamed: 3', 'Unnamed: 4',
'Unnamed: 5', 'Unnamed: 6', 'Unnamed: 7', 'Unnamed: 8', 'Unnamed: 9'],
Enter the
2019-04-10 dtype='object')
15 NaN NaN NaN NaN date to
00:00:00
convert
In [108… df.dtypes
Out[108… id int64 Out[112… taxonomy_id name parent_id parent_name
location_id int64
program_id float64 0 101 Emergency NaN NaN
accepted_payments object 1 101-01 Disaster Response 101 Emergency
alternate_name object
application_process object 2 101-02 Emergency Cash 101 Emergency
audience object
description object 3 101-02-01 Help Pay for Food 101-02 Emergency Cash
eligibility object 4 101-02-02 Help Pay for Healthcare 101-02 Emergency Cash
email object
fees object ... ... ... ... ...
funding_sources object
285 111-01-07 Workplace Rights 111-01 Advocacy & Legal Aid
interpretation_services object
keywords object 286 111-02 Mediation 111 Legal
languages object
name object 287 111-03 Notary 111 Legal
required_documents object
288 111-04 Representation 111 Legal
service_areas object
status object 289 111-05 Translation & Interpretation 111 Legal
wait_time object
website object
290 rows × 4 columns
taxonomy_ids object
dtype: object
In [113… df3 = pd.read_csv("https://raw.githubusercontent.com/datasciencedojo/datasets/master/t
In [109… df1.shape

Out[109… (28, 10) In [114… df3

In [111… df1.info()

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 28 entries, 0 to 27
Data columns (total 10 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Unnamed: 0 0 non-null float64
1 Unnamed: 1 0 non-null float64
2 Unnamed: 2 0 non-null float64
3 Unnamed: 3 3 non-null object
4 Unnamed: 4 12 non-null object
5 Unnamed: 5 7 non-null object
6 Unnamed: 6 0 non-null float64
7 Unnamed: 7 6 non-null object
8 Unnamed: 8 4 non-null object
9 Unnamed: 9 1 non-null object
dtypes: float64(4), object(6)
memory usage: 2.3+ KB

In [112… pd.read_csv("taxonomy.csv")
Out[114… PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket In [116… df3.shape

Braund, Out[116… (891, 12)


A/5
0 1 0 3 Mr. Owen male 22.0 1 0
21171
Harris
In [117… df3.dtypes
Cumings,
Mrs. John Out[117… PassengerId int64
Bradley PC Survived int64
1 2 1 1 female 38.0 1 0
(Florence 17599 Pclass int64
Briggs Name object
Th...
Sex object
Heikkinen, STON/ Age float64
2 3 1 3 Miss. female 26.0 0 0 O2. SibSp int64
Laina 3101282 Parch int64
Ticket object
Futrelle, Fare float64
Mrs.
Cabin object
Jacques
3 4 1 1 female 35.0 1 0 113803 Embarked object
Heath
(Lily May dtype: object
Peel)
In [118… df3['Sex']
Allen, Mr.
4 5 0 3 William male 35.0 0 0 373450 Out[118… 0 male
Henry
1 female
... ... ... ... ... ... ... ... ... ... 2 female
3 female
Montvila, 4 male
886 887 0 2 Rev. male 27.0 0 0 211536 ...
Juozas 886 male
Graham, 887 female
Miss. 888 female
887 888 1 1 female 19.0 0 0 112053 889 male
Margaret
Edith 890 male
Name: Sex, Length: 891, dtype: object
Johnston,
Miss. In [119… df3.columns
W./C.
888 889 0 3 Catherine female NaN 1 2
6607
Helen
"Carrie" Out[119… Index(['PassengerId', 'Survived', 'Pclass', 'Name', 'Sex', 'Age', 'SibSp',
'Parch', 'Ticket', 'Fare', 'Cabin', 'Embarked'],
Behr, Mr. dtype='object')
889 890 1 1 Karl male 26.0 0 0 111369
Howell In [120… df3[['PassengerId', 'Fare', 'Pclass']]
Dooley,
890 891 0 3 male 32.0 0 0 370376
Mr. Patrick

891 rows × 12 columns

In [115… df3.columns

Out[115… Index(['PassengerId', 'Survived', 'Pclass', 'Name', 'Sex', 'Age', 'SibSp',


'Parch', 'Ticket', 'Fare', 'Cabin', 'Embarked'],
dtype='object')
Out[120… PassengerId Fare Pclass Out[9]: Rk Player Pos Age Tm G GS MP FG FGA ... FT% ORB DRB

0 1 7.2500 3 Quincy
0 1 PF 24 NYK 68 22 1287 152 331 ... .784 79 222
Acy
1 2 71.2833 1
Jordan
2 3 7.9250 3 1 2 SG 20 MEM 30 0 248 35 86 ... .609 9 19
Adams
3 4 53.1000 1 Steven
2 3 C 21 OKC 70 67 1771 217 399 ... .502 199 324
Adams
4 5 8.0500 3
Jeff
... ... ... ... 3 4 PF 28 MIN 17 0 215 19 44 ... .579 23 54
Adrien
886 887 13.0000 2 Arron
4 5 SG 29 TOT 78 72 2502 375 884 ... .843 27 220
Afflalo
887 888 30.0000 1
... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
888 889 23.4500 3
Thaddeus
889 890 30.0000 1 670 490 PF 26 TOT 76 68 2434 451 968 ... .655 127 284
Young
890 891 7.7500 3 Thaddeus
671 490 PF 26 MIN 48 48 1605 289 641 ... .682 75 170
Young
891 rows × 3 columns
Thaddeus
672 490 PF 26 BRK 28 20 829 162 327 ... .606 52 114
Young
In [122… #pip install lxml Cody
673 491 C 22 CHO 62 45 1487 172 373 ... .774 97 265
Zeller
Collecting lxml
Downloading lxml-5.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_6 Tyler
4.whl (8.0 MB) 674 492 C 25 BOS 82 59 1731 340 619 ... .823 146 319
Zeller
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.0/8.0 MB 53.6 MB/s eta 0:00:000
0:0100:01 675 rows × 30 columns
Installing collected packages: lxml
Successfully installed lxml-5.1.0
Note: you may need to restart the kernel to use updated packages. In [10]: df4.shape

In [2]: import lxml Out[10]: (675, 30)

In [4]: import pandas as pd In [11]: df4.head()


url_df = pd.read_html("https://www.basketball-reference.com/leagues/NBA_2015_totals.html"

In [5]: type(url_df)

Out[5]: list

In [8]: df4 = url_df[0]

In [9]: df4
Out[11]: Rk Player Pos Age Tm G GS MP FG FGA ... FT% ORB DRB TRB <class 'pandas.core.frame.DataFrame'>
RangeIndex: 675 entries, 0 to 674
Quincy Data columns (total 30 columns):
0 1 PF 24 NYK 68 22 1287 152 331 ... .784 79 222 301
Acy # Column Non-Null Count Dtype
--- ------ -------------- -----
Jordan
1 2 SG 20 MEM 30 0 248 35 86 ... .609 9 19 28 0 Rk 675 non-null object
Adams
1 Player 675 non-null object
Steven 2 Pos 675 non-null object
2 3 C 21 OKC 70 67 1771 217 399 ... .502 199 324 523
Adams 3 Age 675 non-null object
4 Tm 675 non-null object
Jeff 5 G 675 non-null object
3 4 PF 28 MIN 17 0 215 19 44 ... .579 23 54 77
Adrien
6 GS 675 non-null object
Arron 7 MP 675 non-null object
4 5 SG 29 TOT 78 72 2502 375 884 ... .843 27 220 247 8 FG 675 non-null object
Afflalo
9 FGA 675 non-null object
10 FG% 673 non-null object
5 rows × 30 columns
11 3P 675 non-null object
12 3PA 675 non-null object
In [12]: df4.info() 13 3P% 594 non-null object
14 2P 675 non-null object
15 2PA 675 non-null object
16 2P% 671 non-null object
17 eFG% 673 non-null object
18 FT 675 non-null object
19 FTA 675 non-null object
20 FT% 650 non-null object
21 ORB 675 non-null object
22 DRB 675 non-null object
23 TRB 675 non-null object
24 AST 675 non-null object
25 STL 675 non-null object
26 BLK 675 non-null object
27 TOV 675 non-null object
28 PF 675 non-null object
29 PTS 675 non-null object
dtypes: object(30)
memory usage: 158.3+ KB

In [13]: df4.columns

Out[13]: Index(['Rk', 'Player', 'Pos', 'Age', 'Tm', 'G', 'GS', 'MP', 'FG', 'FGA', 'F
G%',
'3P', '3PA', '3P%', '2P', '2PA', '2P%', 'eFG%', 'FT', 'FTA', 'FT%',
'ORB', 'DRB', 'TRB', 'AST', 'STL', 'BLK', 'TOV', 'PF', 'PTS'],
dtype='object')

In [15]: df4.to_csv("players.csv", index=False)

In [16]: url = "https://api.github.com/repos/pandas-dev/pandas/issues"


pd.read_json(url)
Out[16]: url repository_url labels_url comments_url url repository_url labels_url comments_url

https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/


0 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ pandas... pandas pandas... pandas...
pandas... pandas pandas... pandas...

https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/


https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/
15 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
1 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
pandas... pandas pandas... pandas...
pandas... pandas pandas... pandas...

https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/


2 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ 16 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
pandas... pandas pandas... pandas... pandas... pandas pandas... pandas...

https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/


3 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ 17 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
pandas... pandas pandas... pandas... pandas... pandas pandas... pandas...

https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/


4 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ 18 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
pandas... pandas pandas... pandas... pandas... pandas pandas... pandas...

https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/


https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/
5 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
19 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
pandas... pandas pandas... pandas...
pandas... pandas pandas... pandas...
https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/
6 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/
pandas... pandas pandas... pandas... 20 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
pandas... pandas pandas... pandas...
https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/
7 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/
pandas... pandas pandas... pandas... 21 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
pandas... pandas pandas... pandas...
https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/
8 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/
pandas... pandas pandas... pandas... 22 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
pandas... pandas pandas... pandas...
https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/
9 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/
pandas... pandas pandas... pandas... 23 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
pandas... pandas pandas... pandas...
https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/
10 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/
pandas... pandas pandas... pandas...
24 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ pandas... pandas pandas... pandas...
11 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
pandas... pandas pandas... pandas...
https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/
https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ 25 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
12 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ pandas... pandas pandas... pandas...
pandas... pandas pandas... pandas...
https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/
https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ 26 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
13 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ pandas... pandas pandas... pandas...
pandas... pandas pandas... pandas...
https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/
14 https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ 27
repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
url repository_url labels_url comments_url Out[20]: [{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58031',
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas',
pandas... pandas pandas... pandas... 'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58031/
labels{/name}',
https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ 'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5803
28 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ 1/comments',
pandas... pandas pandas... pandas... 'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58031/
events',
https://api.github.com/ https://api.github.com/ https://api.github.com/ https://api.github.com/ 'html_url': 'https://github.com/pandas-dev/pandas/issues/58031',
29 repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/ repos/pandas-dev/
'id': 2210967074,
pandas... pandas pandas... pandas...
'node_id': 'I_kwDOAA0YD86DyK4i',
'number': 58031,
30 rows × 30 columns 'title': 'Inconsistent behaviour of GroupBy for BooleanArray series ',
'user': {'login': 'ziviland',
'id': 1967687,
In [17]: import requests
'node_id': 'MDQ6VXNlcjE5Njc2ODc=',
data = requests.get(url)
'avatar_url': 'https://avatars.githubusercontent.com/u/1967687?v=4',
'gravatar_id': '',
In [18]: data 'url': 'https://api.github.com/users/ziviland',
'html_url': 'https://github.com/ziviland',
Out[18]: <Response [200]> 'followers_url': 'https://api.github.com/users/ziviland/followers',
'following_url': 'https://api.github.com/users/ziviland/following{/other_u
In [19]: df6 = data.json() ser}',
'gists_url': 'https://api.github.com/users/ziviland/gists{/gist_id}',
'starred_url': 'https://api.github.com/users/ziviland/starred{/owner}{/rep
In [20]: df6
o}',
'subscriptions_url': 'https://api.github.com/users/ziviland/subscription
s',
'organizations_url': 'https://api.github.com/users/ziviland/orgs',
'repos_url': 'https://api.github.com/users/ziviland/repos',
'events_url': 'https://api.github.com/users/ziviland/events{/privacy}',
'received_events_url': 'https://api.github.com/users/ziviland/received_eve
nts',
'type': 'User',
'site_admin': False},
'labels': [],
'state': 'open',
'locked': False,
'assignee': None,
'assignees': [],
'milestone': None,
'comments': 0,
'created_at': '2024-03-27T14:31:53Z',
'updated_at': '2024-03-27T14:31:53Z',
'closed_at': None,
'author_association': 'NONE',
'active_lock_reason': None,
'body': 'Lets suppose aggregate function returns int or float. Then if it r
eturns only 0 and 1 then result is converted to BooleanArray. Otherwise, it r
eturns int or float arrays (as expected).\r\n\r\nThis is because this code is
preserving type if series values is not a subclass of **np.ndarray** type. An
d BooleanArray is not.\r\nhttps://github.com/pandas-dev/pandas/blob/b552dc95c
9fa50e9ca2a0c9f9cdb8757f794fedb/pandas/core/groupby/ops.py#L917\r\nSo then th
e code tries to preserve type if it can.\r\n\r\n**Code to reproduce**\r\
n```\r\ndf = pd.DataFrame({0: [1, 2, 2], 1: [True, False, None]})\r\ndf[1] = ions',
df[1].astype("boolean")\r\nprint(df.groupby(by=0).aggregate(lambda s: s.filln 'organizations_url': 'https://api.github.com/users/andremcorreia/orgs',
a(False).mean()).dtypes.values[0])\r\n```\r\nprints boolean.\r\n\r\nIf we cha 'repos_url': 'https://api.github.com/users/andremcorreia/repos',
nge values in array\r\n```\r\ndf = pd.DataFrame({0: [1, 2, 2], 1: [True, Tru 'events_url': 'https://api.github.com/users/andremcorreia/events{/privac
e, None]})\r\ndf[1] = df[1].astype("boolean")\r\nprint(df.groupby(by=0).aggre y}',
gate(lambda s: s.fillna(False).mean()).dtypes.values[0])\r\n```\r\nthen it pr 'received_events_url': 'https://api.github.com/users/andremcorreia/receive
ints float64.\r\n\r\nIf dtype is "bool" (not "boolean"), then groupby always d_events',
returns expected float result.\r\n\r\n```\r\ndf = pd.DataFrame({0: [1, 2, 2], 'type': 'User',
1: [True, False, None]})\r\ndf[1] = df[1].astype("bool")\r\nprint(df.groupb 'site_admin': False},
y(by=0).aggregate(lambda s: s.fillna(False).mean()).dtypes.values[0])\r\ 'labels': [],
n```\r\nprints float64\r\n', 'state': 'open',
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'locked': False,
s/58031/reactions', 'assignee': None,
'total_count': 0, 'assignees': [],
'+1': 0, 'milestone': None,
'-1': 0, 'comments': 0,
'laugh': 0, 'created_at': '2024-03-27T13:50:55Z',
'hooray': 0, 'updated_at': '2024-03-27T13:50:56Z',
'confused': 0, 'closed_at': None,
'heart': 0, 'author_association': 'NONE',
'rocket': 0, 'active_lock_reason': None,
'eyes': 0}, 'draft': False,
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5803 'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul
1/timeline', ls/58030',
'performed_via_github_app': None, 'html_url': 'https://github.com/pandas-dev/pandas/pull/58030',
'state_reason': None}, 'diff_url': 'https://github.com/pandas-dev/pandas/pull/58030.diff',
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58030', 'patch_url': 'https://github.com/pandas-dev/pandas/pull/58030.patch',
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'merged_at': None},
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58030/ 'body': '- [X] closes #57069\r\n- [X] [Tests added and passed](https://pand
labels{/name}', as.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5803 tests) if fixing a bug or adding a new feature\r\n- [X] All [code checks pass
0/comments', ed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codeba
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58030/ se.html#pre-commit).\r\n- [X] Added [type annotations](https://pandas.pydat
events', a.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to n
'html_url': 'https://github.com/pandas-dev/pandas/pull/58030', ew arguments/methods/functions.\r\n- [X] Added an entry in the latest `doc/so
'id': 2210863617, urce/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.\r\n\
'node_id': 'PR_kwDOAA0YD85q7nmu', r\nDataFrameGroupBy.transform with numba was returning the wrong order unless
'number': 58030, the index was monotonically increasing due to the transformed results not bei
'title': 'BUG: Fixed DataFrameGroupBy.transform with numba returning the wr ng correctly reordered. \r\nFixed the test "pandas/tests/groupby/transform/te
ong order with non increasing indexes #57069', st_numba.py::test_index_data_correctly_passed" to expect the correct order in
'user': {'login': 'andremcorreia', the result.\r\nAdded a test "pandas/tests/groupby/transform/test_numba.py::te
'id': 91163660, st_index_order_consistency_preserved" to test DataFrameGroupBy.transform with
'node_id': 'MDQ6VXNlcjkxMTYzNjYw', engine=\'numba\' with a decreasing index.',
'avatar_url': 'https://avatars.githubusercontent.com/u/91163660?v=4', 'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue
'gravatar_id': '', s/58030/reactions',
'url': 'https://api.github.com/users/andremcorreia', 'total_count': 0,
'html_url': 'https://github.com/andremcorreia', '+1': 0,
'followers_url': 'https://api.github.com/users/andremcorreia/followers', '-1': 0,
'following_url': 'https://api.github.com/users/andremcorreia/following{/ot 'laugh': 0,
her_user}', 'hooray': 0,
'gists_url': 'https://api.github.com/users/andremcorreia/gists{/gist_id}', 'confused': 0,
'starred_url': 'https://api.github.com/users/andremcorreia/starred{/owne 'heart': 0,
r}{/repo}', 'rocket': 0,
'subscriptions_url': 'https://api.github.com/users/andremcorreia/subscript 'eyes': 0},
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5803 'state': 'open',
0/timeline', 'locked': False,
'performed_via_github_app': None, 'assignee': None,
'state_reason': None}, 'assignees': [],
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58029', 'milestone': None,
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'comments': 0,
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58029/ 'created_at': '2024-03-27T12:41:40Z',
labels{/name}', 'updated_at': '2024-03-27T15:00:17Z',
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5802 'closed_at': None,
9/comments', 'author_association': 'CONTRIBUTOR',
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58029/ 'active_lock_reason': None,
events', 'draft': False,
'html_url': 'https://github.com/pandas-dev/pandas/pull/58029', 'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul
'id': 2210700416, ls/58029',
'node_id': 'PR_kwDOAA0YD85q7Ea-', 'html_url': 'https://github.com/pandas-dev/pandas/pull/58029',
'number': 58029, 'diff_url': 'https://github.com/pandas-dev/pandas/pull/58029.diff',
'title': 'CLN: enforce `any/all` deprecation with `datetime64`', 'patch_url': 'https://github.com/pandas-dev/pandas/pull/58029.patch',
'user': {'login': 'natmokval', 'merged_at': None},
'id': 91160475, 'body': 'xref #50947, xref #58006\r\n\r\nenforced deprecation of `any/all`
'node_id': 'MDQ6VXNlcjkxMTYwNDc1', with `datetime64`',
'avatar_url': 'https://avatars.githubusercontent.com/u/91160475?v=4', 'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue
'gravatar_id': '', s/58029/reactions',
'url': 'https://api.github.com/users/natmokval', 'total_count': 0,
'html_url': 'https://github.com/natmokval', '+1': 0,
'followers_url': 'https://api.github.com/users/natmokval/followers', '-1': 0,
'following_url': 'https://api.github.com/users/natmokval/following{/othe 'laugh': 0,
r_user}', 'hooray': 0,
'gists_url': 'https://api.github.com/users/natmokval/gists{/gist_id}', 'confused': 0,
'starred_url': 'https://api.github.com/users/natmokval/starred{/owner}{/re 'heart': 0,
po}', 'rocket': 0,
'subscriptions_url': 'https://api.github.com/users/natmokval/subscription 'eyes': 0},
s', 'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5802
'organizations_url': 'https://api.github.com/users/natmokval/orgs', 9/timeline',
'repos_url': 'https://api.github.com/users/natmokval/repos', 'performed_via_github_app': None,
'events_url': 'https://api.github.com/users/natmokval/events{/privacy}', 'state_reason': None},
'received_events_url': 'https://api.github.com/users/natmokval/received_ev {'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58028',
ents', 'repository_url': 'https://api.github.com/repos/pandas-dev/pandas',
'type': 'User', 'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58028/
'site_admin': False}, labels{/name}',
'labels': [{'id': 211029535, 'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5802
'node_id': 'MDU6TGFiZWwyMTEwMjk1MzU=', 8/comments',
'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Clean', 'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58028/
'name': 'Clean', events',
'color': '207de5', 'html_url': 'https://github.com/pandas-dev/pandas/pull/58028',
'default': False, 'id': 2210429200,
'description': None}, 'node_id': 'PR_kwDOAA0YD85q6JDw',
{'id': 2365504383, 'number': 58028,
'node_id': 'MDU6TGFiZWwyMzY1NTA0Mzgz', 'title': 'Fix DataFrame.cumsum failing when dtype is timedelta64[ns]',
'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Reduction%2 'user': {'login': 'Aloqeely',
0Operations', 'id': 52792999,
'name': 'Reduction Operations', 'node_id': 'MDQ6VXNlcjUyNzkyOTk5',
'color': '547c03', 'avatar_url': 'https://avatars.githubusercontent.com/u/52792999?v=4',
'default': False, 'gravatar_id': '',
'description': 'sum, mean, min, max, etc.'}], 'url': 'https://api.github.com/users/Aloqeely',
'html_url': 'https://github.com/Aloqeely', 'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5802
'followers_url': 'https://api.github.com/users/Aloqeely/followers', 8/timeline',
'following_url': 'https://api.github.com/users/Aloqeely/following{/other_u 'performed_via_github_app': None,
ser}', 'state_reason': None},
'gists_url': 'https://api.github.com/users/Aloqeely/gists{/gist_id}', {'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58027',
'starred_url': 'https://api.github.com/users/Aloqeely/starred{/owner}{/rep 'repository_url': 'https://api.github.com/repos/pandas-dev/pandas',
o}', 'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58027/
'subscriptions_url': 'https://api.github.com/users/Aloqeely/subscription labels{/name}',
s', 'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5802
'organizations_url': 'https://api.github.com/users/Aloqeely/orgs', 7/comments',
'repos_url': 'https://api.github.com/users/Aloqeely/repos', 'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58027/
'events_url': 'https://api.github.com/users/Aloqeely/events{/privacy}', events',
'received_events_url': 'https://api.github.com/users/Aloqeely/received_eve 'html_url': 'https://github.com/pandas-dev/pandas/pull/58027',
nts', 'id': 2209769893,
'type': 'User', 'node_id': 'PR_kwDOAA0YD85q35DG',
'site_admin': False}, 'number': 58027,
'labels': [], 'title': 'REGR: Performance of DataFrame.stack where columns are not a Mult
'state': 'open', iIndex',
'locked': False, 'user': {'login': 'rhshadrach',
'assignee': None, 'id': 45562402,
'assignees': [], 'node_id': 'MDQ6VXNlcjQ1NTYyNDAy',
'milestone': None, 'avatar_url': 'https://avatars.githubusercontent.com/u/45562402?v=4',
'comments': 0, 'gravatar_id': '',
'created_at': '2024-03-27T10:31:59Z', 'url': 'https://api.github.com/users/rhshadrach',
'updated_at': '2024-03-27T10:31:59Z', 'html_url': 'https://github.com/rhshadrach',
'closed_at': None, 'followers_url': 'https://api.github.com/users/rhshadrach/followers',
'author_association': 'CONTRIBUTOR', 'following_url': 'https://api.github.com/users/rhshadrach/following{/othe
'active_lock_reason': None, r_user}',
'draft': False, 'gists_url': 'https://api.github.com/users/rhshadrach/gists{/gist_id}',
'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul 'starred_url': 'https://api.github.com/users/rhshadrach/starred{/owner}{/r
ls/58028', epo}',
'html_url': 'https://github.com/pandas-dev/pandas/pull/58028', 'subscriptions_url': 'https://api.github.com/users/rhshadrach/subscription
'diff_url': 'https://github.com/pandas-dev/pandas/pull/58028.diff', s',
'patch_url': 'https://github.com/pandas-dev/pandas/pull/58028.patch', 'organizations_url': 'https://api.github.com/users/rhshadrach/orgs',
'merged_at': None}, 'repos_url': 'https://api.github.com/users/rhshadrach/repos',
'body': '- [x] closes #57956 \r\n- [x] [Tests added and passed](https://pan 'events_url': 'https://api.github.com/users/rhshadrach/events{/privacy}',
das.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writin 'received_events_url': 'https://api.github.com/users/rhshadrach/received_e
g-tests) if fixing a bug or adding a new feature\r\n- [x] All [code checks pa vents',
ssed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_code 'type': 'User',
base.html#pre-commit).\r\n- [ ] Added [type annotations](https://pandas.pydat 'site_admin': False},
a.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to n 'labels': [{'id': 8935311,
ew arguments/methods/functions.\r\n- [ ] Added an entry in the latest `doc/so 'node_id': 'MDU6TGFiZWw4OTM1MzEx',
urce/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.\r\n', 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Performanc
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue e',
s/58028/reactions', 'name': 'Performance',
'total_count': 0, 'color': 'a10c02',
'+1': 0, 'default': False,
'-1': 0, 'description': 'Memory or execution speed performance'},
'laugh': 0, {'id': 13098779,
'hooray': 0, 'node_id': 'MDU6TGFiZWwxMzA5ODc3OQ==',
'confused': 0, 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Reshaping',
'heart': 0, 'name': 'Reshaping',
'rocket': 0, 'color': '02d7e1',
'eyes': 0}, 'default': False,
'description': 'Concat, Merge/Join, Stack/Unstack, Explode'}, 'comments': 0,
{'id': 32815646, 'created_at': '2024-03-27T03:43:05Z',
'node_id': 'MDU6TGFiZWwzMjgxNTY0Ng==', 'updated_at': '2024-03-27T03:43:05Z',
'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Regressio 'closed_at': None,
n', 'author_association': 'MEMBER',
'name': 'Regression', 'active_lock_reason': None,
'color': 'e11d21', 'draft': False,
'default': False, 'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul
'description': 'Functionality that used to work in a prior pandas versio ls/58027',
n'}], 'html_url': 'https://github.com/pandas-dev/pandas/pull/58027',
'state': 'open', 'diff_url': 'https://github.com/pandas-dev/pandas/pull/58027.diff',
'locked': False, 'patch_url': 'https://github.com/pandas-dev/pandas/pull/58027.patch',
'assignee': None, 'merged_at': None},
'assignees': [], 'body': "- [x] closes #57302 (Replace xxxx with the GitHub issue number)\r\
'milestone': {'url': 'https://api.github.com/repos/pandas-dev/pandas/milest n- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/dev
ones/102', elopment/contributing_codebase.html#writing-tests) if fixing a bug or adding
'html_url': 'https://github.com/pandas-dev/pandas/milestone/102', a new feature\r\n- [ ] All [code checks passed](https://pandas.pydata.org/pan
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/milestones/1 das-docs/dev/development/contributing_codebase.html#pre-commit).\r\n- [ ] Add
02/labels', ed [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/c
'id': 9021906, ontributing_codebase.html#type-hints) to new arguments/methods/functions.\r\
'node_id': 'MI_kwDOAA0YD84AianS', n- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if
'number': 102, fixing a bug or adding a new feature.\r\n\r\nThanks @DeaMariaLeon for identif
'title': '3.0', ying this regression and @jorisvandenbossche for the solution used here.\r\n\
'description': '', r\nASVs\r\n\r\n```\r\n| Change | Before [e51039af] <enh_fillna_allow_non
'creator': {'login': 'jbrockmendel', e~1> | After [664c54b8] <regr_perf_stack> | Ratio | Benchmark (Paramete
'id': 8078968, r) |\r\n|----------
'node_id': 'MDQ6VXNlcjgwNzg5Njg=', |-----------------------------------------------
'avatar_url': 'https://avatars.githubusercontent.com/u/8078968?v=4', |--------------------------------------|---------
'gravatar_id': '', |------------------------------------------------------------------------|\r\
'url': 'https://api.github.com/users/jbrockmendel', n| - | 304±2ms | 44.2±0.4ms
'html_url': 'https://github.com/jbrockmendel', | 0.15 | reshape.ReshapeExtensionDtype.time_stack('datetime64[ns, US/Pacif
'followers_url': 'https://api.github.com/users/jbrockmendel/followers', ic]') |\r\n| - | 304±2ms | 4
'following_url': 'https://api.github.com/users/jbrockmendel/following{/ot 3.7±0.2ms | 0.14 | reshape.ReshapeExtensionDtyp
her_user}', e.time_stack('Period[s]') |\r\n| - | 294±0.7ms
'gists_url': 'https://api.github.com/users/jbrockmendel/gists{/gist_id}', | 40.8±0.3ms | 0.14 | reshape.ReshapeMaskedArray
'starred_url': 'https://api.github.com/users/jbrockmendel/starred{/owne Dtype.time_stack('Float64') |\r\n| - | 291±2ms
r}{/repo}', | 40.7±0.2ms | 0.14 | reshape.ReshapeMaskedArray
'subscriptions_url': 'https://api.github.com/users/jbrockmendel/subscript Dtype.time_stack('Int64') |\r\n```",
ions', 'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue
'organizations_url': 'https://api.github.com/users/jbrockmendel/orgs', s/58027/reactions',
'repos_url': 'https://api.github.com/users/jbrockmendel/repos', 'total_count': 0,
'events_url': 'https://api.github.com/users/jbrockmendel/events{/privac '+1': 0,
y}', '-1': 0,
'received_events_url': 'https://api.github.com/users/jbrockmendel/receive 'laugh': 0,
d_events', 'hooray': 0,
'type': 'User', 'confused': 0,
'site_admin': False}, 'heart': 0,
'open_issues': 51, 'rocket': 0,
'closed_issues': 481, 'eyes': 0},
'state': 'open', 'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5802
'created_at': '2023-02-08T18:16:49Z', 7/timeline',
'updated_at': '2024-03-27T03:43:05Z', 'performed_via_github_app': None,
'due_on': '2024-04-01T07:00:00Z', 'state_reason': None},
'closed_at': None}, {'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58026',
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'body': 'Or is the idea to change this to a FutureWarning first and wait an
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58026/ other cycle?',
labels{/name}', 'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5802 s/58026/reactions',
6/comments', 'total_count': 0,
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58026/ '+1': 0,
events', '-1': 0,
'html_url': 'https://github.com/pandas-dev/pandas/pull/58026', 'laugh': 0,
'id': 2209752885, 'hooray': 0,
'node_id': 'PR_kwDOAA0YD85q31Fu', 'confused': 0,
'number': 58026, 'heart': 0,
'title': 'DEPR: allowing Manager in DataFrame/Series constructors', 'rocket': 0,
'user': {'login': 'jbrockmendel', 'eyes': 0},
'id': 8078968, 'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5802
'node_id': 'MDQ6VXNlcjgwNzg5Njg=', 6/timeline',
'avatar_url': 'https://avatars.githubusercontent.com/u/8078968?v=4', 'performed_via_github_app': None,
'gravatar_id': '', 'state_reason': None},
'url': 'https://api.github.com/users/jbrockmendel', {'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58025',
'html_url': 'https://github.com/jbrockmendel', 'repository_url': 'https://api.github.com/repos/pandas-dev/pandas',
'followers_url': 'https://api.github.com/users/jbrockmendel/followers', 'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58025/
'following_url': 'https://api.github.com/users/jbrockmendel/following{/oth labels{/name}',
er_user}', 'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5802
'gists_url': 'https://api.github.com/users/jbrockmendel/gists{/gist_id}', 5/comments',
'starred_url': 'https://api.github.com/users/jbrockmendel/starred{/owne 'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58025/
r}{/repo}', events',
'subscriptions_url': 'https://api.github.com/users/jbrockmendel/subscripti 'html_url': 'https://github.com/pandas-dev/pandas/pull/58025',
ons', 'id': 2209729675,
'organizations_url': 'https://api.github.com/users/jbrockmendel/orgs', 'node_id': 'PR_kwDOAA0YD85q3v8H',
'repos_url': 'https://api.github.com/users/jbrockmendel/repos', 'number': 58025,
'events_url': 'https://api.github.com/users/jbrockmendel/events{/privac 'title': 'CLN: remove no-longer-needed warning filters',
y}', 'user': {'login': 'jbrockmendel',
'received_events_url': 'https://api.github.com/users/jbrockmendel/receive 'id': 8078968,
d_events', 'node_id': 'MDQ6VXNlcjgwNzg5Njg=',
'type': 'User', 'avatar_url': 'https://avatars.githubusercontent.com/u/8078968?v=4',
'site_admin': False}, 'gravatar_id': '',
'labels': [], 'url': 'https://api.github.com/users/jbrockmendel',
'state': 'open', 'html_url': 'https://github.com/jbrockmendel',
'locked': False, 'followers_url': 'https://api.github.com/users/jbrockmendel/followers',
'assignee': None, 'following_url': 'https://api.github.com/users/jbrockmendel/following{/oth
'assignees': [], er_user}',
'milestone': None, 'gists_url': 'https://api.github.com/users/jbrockmendel/gists{/gist_id}',
'comments': 0, 'starred_url': 'https://api.github.com/users/jbrockmendel/starred{/owne
'created_at': '2024-03-27T03:34:23Z', r}{/repo}',
'updated_at': '2024-03-27T03:34:23Z', 'subscriptions_url': 'https://api.github.com/users/jbrockmendel/subscripti
'closed_at': None, ons',
'author_association': 'MEMBER', 'organizations_url': 'https://api.github.com/users/jbrockmendel/orgs',
'active_lock_reason': None, 'repos_url': 'https://api.github.com/users/jbrockmendel/repos',
'draft': False, 'events_url': 'https://api.github.com/users/jbrockmendel/events{/privac
'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul y}',
ls/58026', 'received_events_url': 'https://api.github.com/users/jbrockmendel/receive
'html_url': 'https://github.com/pandas-dev/pandas/pull/58026', d_events',
'diff_url': 'https://github.com/pandas-dev/pandas/pull/58026.diff', 'type': 'User',
'patch_url': 'https://github.com/pandas-dev/pandas/pull/58026.patch', 'site_admin': False},
'merged_at': None}, 'labels': [],
'state': 'open', 'title': 'BUG: Performing groupby with `as_index=False` when `df.columns.na
'locked': False, me` is not None drops the name',
'assignee': None, 'user': {'login': 'sfc-gh-joshi',
'assignees': [], 'id': 149419494,
'milestone': None, 'node_id': 'U_kgDOCOf15g',
'comments': 0, 'avatar_url': 'https://avatars.githubusercontent.com/u/149419494?v=4',
'created_at': '2024-03-27T03:12:58Z', 'gravatar_id': '',
'updated_at': '2024-03-27T03:12:58Z', 'url': 'https://api.github.com/users/sfc-gh-joshi',
'closed_at': None, 'html_url': 'https://github.com/sfc-gh-joshi',
'author_association': 'MEMBER', 'followers_url': 'https://api.github.com/users/sfc-gh-joshi/followers',
'active_lock_reason': None, 'following_url': 'https://api.github.com/users/sfc-gh-joshi/following{/oth
'draft': False, er_user}',
'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul 'gists_url': 'https://api.github.com/users/sfc-gh-joshi/gists{/gist_id}',
ls/58025', 'starred_url': 'https://api.github.com/users/sfc-gh-joshi/starred{/owne
'html_url': 'https://github.com/pandas-dev/pandas/pull/58025', r}{/repo}',
'diff_url': 'https://github.com/pandas-dev/pandas/pull/58025.diff', 'subscriptions_url': 'https://api.github.com/users/sfc-gh-joshi/subscripti
'patch_url': 'https://github.com/pandas-dev/pandas/pull/58025.patch', ons',
'merged_at': None}, 'organizations_url': 'https://api.github.com/users/sfc-gh-joshi/orgs',
'body': '- [ ] closes #xxxx (Replace xxxx with the GitHub issue number)\r\ 'repos_url': 'https://api.github.com/users/sfc-gh-joshi/repos',
n- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/dev 'events_url': 'https://api.github.com/users/sfc-gh-joshi/events{/privac
elopment/contributing_codebase.html#writing-tests) if fixing a bug or adding y}',
a new feature\r\n- [ ] All [code checks passed](https://pandas.pydata.org/pan 'received_events_url': 'https://api.github.com/users/sfc-gh-joshi/receive
das-docs/dev/development/contributing_codebase.html#pre-commit).\r\n- [ ] Add d_events',
ed [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/c 'type': 'User',
ontributing_codebase.html#type-hints) to new arguments/methods/functions.\r\ 'site_admin': False},
n- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if 'labels': [{'id': 134699,
fixing a bug or adding a new feature.\r\n', 'node_id': 'MDU6TGFiZWwxMzQ2OTk=',
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Docs',
s/58025/reactions', 'name': 'Docs',
'total_count': 0, 'color': '3465A4',
'+1': 0, 'default': False,
'-1': 0, 'description': None},
'laugh': 0, {'id': 233160,
'hooray': 0, 'node_id': 'MDU6TGFiZWwyMzMxNjA=',
'confused': 0, 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Groupby',
'heart': 0, 'name': 'Groupby',
'rocket': 0, 'color': '729FCF',
'eyes': 0}, 'default': False,
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5802 'description': None}],
5/timeline', 'state': 'open',
'performed_via_github_app': None, 'locked': False,
'state_reason': None}, 'assignee': None,
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58024', 'assignees': [],
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'milestone': None,
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58024/ 'comments': 1,
labels{/name}', 'created_at': '2024-03-26T23:57:54Z',
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5802 'updated_at': '2024-03-27T02:52:28Z',
4/comments', 'closed_at': None,
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58024/ 'author_association': 'NONE',
events', 'active_lock_reason': None,
'html_url': 'https://github.com/pandas-dev/pandas/issues/58024', 'body': '### Pandas version checks\n\n- [X] I have checked that this issue
'id': 2209551122, has not already been reported.\n\n- [X] I have confirmed this bug exists on t
'node_id': 'I_kwDOAA0YD86DsxMS', he [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pa
'number': 58024, ndas.\n\n- [X] I have confirmed this bug exists on the [main branch](http
s://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-de 'heart': 0,
velopment-version-of-pandas) of pandas.\n\n\n### Reproducible Example\n\n```p 'rocket': 0,
ython\nimport pandas as pd\r\ndf = pd.DataFrame(\r\n [[1, 2, 3]],\r\n c 'eyes': 0},
olumns=pd.Index(["A", "B", "C"], name="alpha")\r\n)\r\ndf.groupby(by="A", a 'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5802
s_index=False)["B"].sum()\n```\n\n\n### Issue Description\n\nOutput of the ab 4/timeline',
ove example:\r\n```\r\n>>> df\r\nalpha A B C\r\n0 1 2 3\r\n>>> df.g 'performed_via_github_app': None,
roupby(by="A", as_index=False)["B"].sum()\r\n A B\r\n0 1 2\r\n```\r\n\r\ 'state_reason': None},
nThe `name` field of the columns `Index` object is dropped after the groupby {'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58022',
operation.\r\n```\r\n>>> df.groupby(by="A", as_index=False)["B"].sum().column 'repository_url': 'https://api.github.com/repos/pandas-dev/pandas',
s\r\nIndex([\'A\', \'B\'], dtype=\'object\')\r\n```\r\n\r\nIn pandas 1.5, the 'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58022/
name was retained:\r\n```\r\n>>> pd.__version__\r\n\'1.5.3\'\r\n>>> df.groupb labels{/name}',
y(by="A", as_index=False)["B"].sum()\r\nalpha A B\r\n0 1 2\r\n>>> d 'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5802
f.groupby(by="A", as_index=False)["B"].sum().columns\r\nIndex([\'A\', \'B\'], 2/comments',
dtype=\'object\', name=\'alpha\')\r\n```\n\n### Expected Behavior\n\nIt is un 'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58022/
clear whether this change was intentional between pandas 1.5/2.0; I could not events',
find any mention of this in the issue tracker or release notes. If this was i 'html_url': 'https://github.com/pandas-dev/pandas/pull/58022',
ntentional, it should be mentioned briefly in groupby documentation; if not, 'id': 2209517133,
then it should be fixed to preserve the name as before.\n\n### Installed Vers 'node_id': 'PR_kwDOAA0YD85q3CcZ',
ions\n\n<details>\r\n\r\nINSTALLED VERSIONS\r\n------------------\r\ncommit 'number': 58022,
: 7fe86b67d3782d0c35b9284900e4aa9dd827718a\r\npython : 3.1 'title': 'DEPR: freq keyword in PeriodArray',
1.7.final.0\r\npython-bits : 64\r\nOS : Darwin\ 'user': {'login': 'jbrockmendel',
r\nOS-release : 23.4.0\r\nVersion : Darwin Kernel Ve 'id': 8078968,
rsion 23.4.0: Wed Feb 21 21:45:49 PST 2024; root:xnu-10063.101.15~2/RELEASE_A 'node_id': 'MDQ6VXNlcjgwNzg5Njg=',
RM64_T6020\r\nmachine : arm64\r\nprocessor : arm\r\ 'avatar_url': 'https://avatars.githubusercontent.com/u/8078968?v=4',
nbyteorder : little\r\nLC_ALL : None\r\nLANG 'gravatar_id': '',
: en_US.UTF-8\r\nLOCALE : en_US.UTF-8\r\n\r\npandas 'url': 'https://api.github.com/users/jbrockmendel',
: 3.0.0.dev0+263.g7fe86b67d3\r\nnumpy : 1.26.4\r\npytz 'html_url': 'https://github.com/jbrockmendel',
: 2024.1\r\ndateutil : 2.8.2\r\nsetuptools : 68.2.2\ 'followers_url': 'https://api.github.com/users/jbrockmendel/followers',
r\npip : 23.3.1\r\nCython : None\r\npytest 'following_url': 'https://api.github.com/users/jbrockmendel/following{/oth
: None\r\nhypothesis : None\r\nsphinx : None\r\nblo er_user}',
sc : None\r\nfeather : None\r\nxlsxwriter 'gists_url': 'https://api.github.com/users/jbrockmendel/gists{/gist_id}',
: None\r\nlxml.etree : None\r\nhtml5lib : None\r\npym 'starred_url': 'https://api.github.com/users/jbrockmendel/starred{/owne
ysql : None\r\npsycopg2 : None\r\njinja2 r}{/repo}',
: None\r\nIPython : None\r\npandas_datareader : None\r\nadb 'subscriptions_url': 'https://api.github.com/users/jbrockmendel/subscripti
c-driver-postgresql: None\r\nadbc-driver-sqlite : None\r\nbs4 ons',
: None\r\nbottleneck : None\r\ndataframe-api-compat : None\r\nfas 'organizations_url': 'https://api.github.com/users/jbrockmendel/orgs',
tparquet : None\r\nfsspec : None\r\ngcsfs 'repos_url': 'https://api.github.com/users/jbrockmendel/repos',
: None\r\nmatplotlib : None\r\nnumba : None\r\nnum 'events_url': 'https://api.github.com/users/jbrockmendel/events{/privac
expr : None\r\nodfpy : None\r\nopenpyxl y}',
: None\r\npandas_gbq : None\r\npyarrow : 15.0.0\r\np 'received_events_url': 'https://api.github.com/users/jbrockmendel/receive
yreadstat : None\r\npython-calamine : None\r\npyxlsb d_events',
: None\r\ns3fs : None\r\nscipy : None\r\nsql 'type': 'User',
alchemy : None\r\ntables : None\r\ntabulate 'site_admin': False},
: None\r\nxarray : None\r\nxlrd : None\r\nzst 'labels': [{'id': 60635328,
andard : None\r\ntzdata : 2023.4\r\nqtpy 'node_id': 'MDU6TGFiZWw2MDYzNTMyOA==',
: None\r\npyqt5 : None\r\n</details>\r\n', 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Period',
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'name': 'Period',
s/58024/reactions', 'color': 'eb6420',
'total_count': 0, 'default': False,
'+1': 0, 'description': 'Period data type'},
'-1': 0, {'id': 211029535,
'laugh': 0, 'node_id': 'MDU6TGFiZWwyMTEwMjk1MzU=',
'hooray': 0, 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Clean',
'confused': 0, 'name': 'Clean',
'color': '207de5', 'id': 2209516947,
'default': False, 'node_id': 'PR_kwDOAA0YD85q3CaB',
'description': None}], 'number': 58021,
'state': 'open', 'title': 'DEPR: resample with PeriodIndex',
'locked': False, 'user': {'login': 'jbrockmendel',
'assignee': None, 'id': 8078968,
'assignees': [], 'node_id': 'MDQ6VXNlcjgwNzg5Njg=',
'milestone': None, 'avatar_url': 'https://avatars.githubusercontent.com/u/8078968?v=4',
'comments': 0, 'gravatar_id': '',
'created_at': '2024-03-26T23:24:10Z', 'url': 'https://api.github.com/users/jbrockmendel',
'updated_at': '2024-03-27T02:58:42Z', 'html_url': 'https://github.com/jbrockmendel',
'closed_at': None, 'followers_url': 'https://api.github.com/users/jbrockmendel/followers',
'author_association': 'MEMBER', 'following_url': 'https://api.github.com/users/jbrockmendel/following{/oth
'active_lock_reason': None, er_user}',
'draft': False, 'gists_url': 'https://api.github.com/users/jbrockmendel/gists{/gist_id}',
'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul 'starred_url': 'https://api.github.com/users/jbrockmendel/starred{/owne
ls/58022', r}{/repo}',
'html_url': 'https://github.com/pandas-dev/pandas/pull/58022', 'subscriptions_url': 'https://api.github.com/users/jbrockmendel/subscripti
'diff_url': 'https://github.com/pandas-dev/pandas/pull/58022.diff', ons',
'patch_url': 'https://github.com/pandas-dev/pandas/pull/58022.patch', 'organizations_url': 'https://api.github.com/users/jbrockmendel/orgs',
'merged_at': None}, 'repos_url': 'https://api.github.com/users/jbrockmendel/repos',
'body': '- [ ] closes #xxxx (Replace xxxx with the GitHub issue number)\r\ 'events_url': 'https://api.github.com/users/jbrockmendel/events{/privac
n- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/dev y}',
elopment/contributing_codebase.html#writing-tests) if fixing a bug or adding 'received_events_url': 'https://api.github.com/users/jbrockmendel/receive
a new feature\r\n- [ ] All [code checks passed](https://pandas.pydata.org/pan d_events',
das-docs/dev/development/contributing_codebase.html#pre-commit).\r\n- [ ] Add 'type': 'User',
ed [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/c 'site_admin': False},
ontributing_codebase.html#type-hints) to new arguments/methods/functions.\r\ 'labels': [{'id': 60635328,
n- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if 'node_id': 'MDU6TGFiZWw2MDYzNTMyOA==',
fixing a bug or adding a new feature.\r\n', 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Period',
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'name': 'Period',
s/58022/reactions', 'color': 'eb6420',
'total_count': 0, 'default': False,
'+1': 0, 'description': 'Period data type'},
'-1': 0, {'id': 74975453,
'laugh': 0, 'node_id': 'MDU6TGFiZWw3NDk3NTQ1Mw==',
'hooray': 0, 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Resample',
'confused': 0, 'name': 'Resample',
'heart': 0, 'color': '207de5',
'rocket': 0, 'default': False,
'eyes': 0}, 'description': 'resample method'},
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5802 {'id': 211029535,
2/timeline', 'node_id': 'MDU6TGFiZWwyMTEwMjk1MzU=',
'performed_via_github_app': None, 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Clean',
'state_reason': None}, 'name': 'Clean',
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58021', 'color': '207de5',
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'default': False,
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58021/ 'description': None}],
labels{/name}', 'state': 'open',
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5802 'locked': False,
1/comments', 'assignee': None,
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58021/ 'assignees': [],
events', 'milestone': None,
'html_url': 'https://github.com/pandas-dev/pandas/pull/58021', 'comments': 0,
'created_at': '2024-03-26T23:23:58Z', 'url': 'https://api.github.com/users/rhshadrach',
'updated_at': '2024-03-27T03:15:37Z', 'html_url': 'https://github.com/rhshadrach',
'closed_at': None, 'followers_url': 'https://api.github.com/users/rhshadrach/followers',
'author_association': 'MEMBER', 'following_url': 'https://api.github.com/users/rhshadrach/following{/othe
'active_lock_reason': None, r_user}',
'draft': False, 'gists_url': 'https://api.github.com/users/rhshadrach/gists{/gist_id}',
'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul 'starred_url': 'https://api.github.com/users/rhshadrach/starred{/owner}{/r
ls/58021', epo}',
'html_url': 'https://github.com/pandas-dev/pandas/pull/58021', 'subscriptions_url': 'https://api.github.com/users/rhshadrach/subscription
'diff_url': 'https://github.com/pandas-dev/pandas/pull/58021.diff', s',
'patch_url': 'https://github.com/pandas-dev/pandas/pull/58021.patch', 'organizations_url': 'https://api.github.com/users/rhshadrach/orgs',
'merged_at': None}, 'repos_url': 'https://api.github.com/users/rhshadrach/repos',
'body': '- [ ] closes #xxxx (Replace xxxx with the GitHub issue number)\r\ 'events_url': 'https://api.github.com/users/rhshadrach/events{/privacy}',
n- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/dev 'received_events_url': 'https://api.github.com/users/rhshadrach/received_e
elopment/contributing_codebase.html#writing-tests) if fixing a bug or adding vents',
a new feature\r\n- [ ] All [code checks passed](https://pandas.pydata.org/pan 'type': 'User',
das-docs/dev/development/contributing_codebase.html#pre-commit).\r\n- [ ] Add 'site_admin': False},
ed [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/c 'labels': [{'id': 2822342,
ontributing_codebase.html#type-hints) to new arguments/methods/functions.\r\ 'node_id': 'MDU6TGFiZWwyODIyMzQy',
n- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Missing-dat
fixing a bug or adding a new feature.\r\n', a',
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'name': 'Missing-data',
s/58021/reactions', 'color': 'd7e102',
'total_count': 0, 'default': False,
'+1': 0, 'description': 'np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate'},
'-1': 0, {'id': 8935311,
'laugh': 0, 'node_id': 'MDU6TGFiZWw4OTM1MzEx',
'hooray': 0, 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Performanc
'confused': 0, e',
'heart': 0, 'name': 'Performance',
'rocket': 0, 'color': 'a10c02',
'eyes': 0}, 'default': False,
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5802 'description': 'Memory or execution speed performance'},
1/timeline', {'id': 211029535,
'performed_via_github_app': None, 'node_id': 'MDU6TGFiZWwyMTEwMjk1MzU=',
'state_reason': None}, 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Clean',
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58019', 'name': 'Clean',
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'color': '207de5',
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58019/ 'default': False,
labels{/name}', 'description': None},
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5801 {'id': 2365504383,
9/comments', 'node_id': 'MDU6TGFiZWwyMzY1NTA0Mzgz',
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58019/ 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Reduction%2
events', 0Operations',
'html_url': 'https://github.com/pandas-dev/pandas/pull/58019', 'name': 'Reduction Operations',
'id': 2209391813, 'color': '547c03',
'node_id': 'PR_kwDOAA0YD85q2mkR', 'default': False,
'number': 58019, 'description': 'sum, mean, min, max, etc.'}],
'title': 'CLN/PERF: Simplify argmin/argmax', 'state': 'open',
'user': {'login': 'rhshadrach', 'locked': False,
'id': 45562402, 'assignee': None,
'node_id': 'MDQ6VXNlcjQ1NTYyNDAy', 'assignees': [],
'avatar_url': 'https://avatars.githubusercontent.com/u/45562402?v=4', 'milestone': None,
'gravatar_id': '', 'comments': 0,
'created_at': '2024-03-26T21:47:08Z', '-1': 0,
'updated_at': '2024-03-26T22:31:23Z', 'laugh': 0,
'closed_at': None, 'hooray': 0,
'author_association': 'MEMBER', 'confused': 0,
'active_lock_reason': None, 'heart': 0,
'draft': True, 'rocket': 0,
'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul 'eyes': 0},
ls/58019', 'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5801
'html_url': 'https://github.com/pandas-dev/pandas/pull/58019', 9/timeline',
'diff_url': 'https://github.com/pandas-dev/pandas/pull/58019.diff', 'performed_via_github_app': None,
'patch_url': 'https://github.com/pandas-dev/pandas/pull/58019.patch', 'state_reason': None},
'merged_at': None}, {'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58018',
'body': '- [ ] closes #xxxx (Replace xxxx with the GitHub issue number)\r\ 'repository_url': 'https://api.github.com/repos/pandas-dev/pandas',
n- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/dev 'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58018/
elopment/contributing_codebase.html#writing-tests) if fixing a bug or adding labels{/name}',
a new feature\r\n- [ ] All [code checks passed](https://pandas.pydata.org/pan 'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5801
das-docs/dev/development/contributing_codebase.html#pre-commit).\r\n- [ ] Add 8/comments',
ed [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/c 'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58018/
ontributing_codebase.html#type-hints) to new arguments/methods/functions.\r\ events',
n- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if 'html_url': 'https://github.com/pandas-dev/pandas/pull/58018',
fixing a bug or adding a new feature.\r\n\r\nRef: https://github.com/pandas-d 'id': 2209144889,
ev/pandas/pull/57971#discussion_r1539849666\r\n\r\nFrom the test `test_idxmin 'node_id': 'PR_kwDOAA0YD85q1vvU',
max_object_dtype`, the following used to raise on L2 but is now successfu 'number': 58018,
l.\r\n\r\n```\r\nser3 = Series(["foo", "foo", "bar", "bar", None, np.nan, "ba 'title': 'PERF: Allow Index.to_frame to return RangeIndex columns',
z"])\r\nresult = ser3.idxmax(skipna=True)\r\nexpected = 0\r\nassert result == 'user': {'login': 'mroeschke',
expected\r\n```\r\n\r\nPreviously, we would raise an error that we can\'t com 'id': 10647082,
pare strings (e.g. `foo`) to floats (`np.nan`). I think it makes sense to all 'node_id': 'MDQ6VXNlcjEwNjQ3MDgy',
ow this result.\r\n\r\nASVs:\r\n\r\n```\r\n| Change | Before [e9381aed] <cl 'avatar_url': 'https://avatars.githubusercontent.com/u/10647082?v=4',
n_argmin_argmax~3> | After [7ad5f948] <cln_argmin_argmax> | Ratio | Ben 'gravatar_id': '',
chmark (Parameter) |\r\n|---------- 'url': 'https://api.github.com/users/mroeschke',
|------------------------------------------- 'html_url': 'https://github.com/mroeschke',
|----------------------------------------|--------- 'followers_url': 'https://api.github.com/users/mroeschke/followers',
|---------------------------------------------------------------|\r\n| - 'following_url': 'https://api.github.com/users/mroeschke/following{/othe
| 143±3μs | 122±0.8μs r_user}',
| 0.86 | series_methods.NanOps.time_func(\'argmax\', 1000000, \'int64\') 'gists_url': 'https://api.github.com/users/mroeschke/gists{/gist_id}',
|\r\n| - | 84.0±2μs | 62.4±0.7μs 'starred_url': 'https://api.github.com/users/mroeschke/starred{/owner}{/re
| 0.74 | series_methods.NanOps.time_func(\'argmax\', 1000000, \'int32\') po}',
|\r\n| - | 371±3μs | 265±1μs 'subscriptions_url': 'https://api.github.com/users/mroeschke/subscription
| 0.71 | series_methods.NanOps.time_func(\'argmax\', 1000000, \'float64\') s',
|\r\n| - | 7.79±0.1μs | 5.37±0.2μs 'organizations_url': 'https://api.github.com/users/mroeschke/orgs',
| 0.69 | series_methods.NanOps.time_func(\'argmax\', 1000, \'float64\') 'repos_url': 'https://api.github.com/users/mroeschke/repos',
|\r\n| - | 38.6±1μs | 19.1±0.4μs 'events_url': 'https://api.github.com/users/mroeschke/events{/privacy}',
| 0.5 | series_methods.NanOps.time_func(\'argmax\', 1000000, \'int8\') 'received_events_url': 'https://api.github.com/users/mroeschke/received_ev
|\r\n| - | 3.84±0.01μs | 1.25±0μs ents',
| 0.33 | series_methods.NanOps.time_func(\'argmax\', 1000, \'int64\') 'type': 'User',
|\r\n| - | 3.76±0.03μs | 1.16±0.01μs 'site_admin': False},
| 0.31 | series_methods.NanOps.time_func(\'argmax\', 1000, \'int32\') 'labels': [{'id': 8935311,
|\r\n| - | 3.84±0.03μs | 1.20±0.01μs 'node_id': 'MDU6TGFiZWw4OTM1MzEx',
| 0.31 | series_methods.NanOps.time_func(\'argmax\', 1000, \'int8\') 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Performanc
|\r\n```', e',
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'name': 'Performance',
s/58019/reactions', 'color': 'a10c02',
'total_count': 0, 'default': False,
'+1': 0, 'description': 'Memory or execution speed performance'},
{'id': 1218227310, ces',
'node_id': 'MDU6TGFiZWwxMjE4MjI3MzEw', 'user': {'login': 'shriyakalakata',
'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Index', 'id': 87483933,
'name': 'Index', 'node_id': 'MDQ6VXNlcjg3NDgzOTMz',
'color': 'e99695', 'avatar_url': 'https://avatars.githubusercontent.com/u/87483933?v=4',
'default': False, 'gravatar_id': '',
'description': 'Related to the Index class or subclasses'}], 'url': 'https://api.github.com/users/shriyakalakata',
'state': 'open', 'html_url': 'https://github.com/shriyakalakata',
'locked': False, 'followers_url': 'https://api.github.com/users/shriyakalakata/followers',
'assignee': None, 'following_url': 'https://api.github.com/users/shriyakalakata/following{/o
'assignees': [], ther_user}',
'milestone': None, 'gists_url': 'https://api.github.com/users/shriyakalakata/gists{/gist_i
'comments': 0, d}',
'created_at': '2024-03-26T19:29:43Z', 'starred_url': 'https://api.github.com/users/shriyakalakata/starred{/owne
'updated_at': '2024-03-26T21:32:14Z', r}{/repo}',
'closed_at': None, 'subscriptions_url': 'https://api.github.com/users/shriyakalakata/subscrip
'author_association': 'MEMBER', tions',
'active_lock_reason': None, 'organizations_url': 'https://api.github.com/users/shriyakalakata/orgs',
'draft': False, 'repos_url': 'https://api.github.com/users/shriyakalakata/repos',
'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul 'events_url': 'https://api.github.com/users/shriyakalakata/events{/privac
ls/58018', y}',
'html_url': 'https://github.com/pandas-dev/pandas/pull/58018', 'received_events_url': 'https://api.github.com/users/shriyakalakata/receiv
'diff_url': 'https://github.com/pandas-dev/pandas/pull/58018.diff', ed_events',
'patch_url': 'https://github.com/pandas-dev/pandas/pull/58018.patch', 'type': 'User',
'merged_at': None}, 'site_admin': False},
'body': 'Discovered in https://github.com/pandas-dev/pandas/pull/57441', 'labels': [],
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'state': 'open',
s/58018/reactions', 'locked': False,
'total_count': 0, 'assignee': None,
'+1': 0, 'assignees': [],
'-1': 0, 'milestone': None,
'laugh': 0, 'comments': 0,
'hooray': 0, 'created_at': '2024-03-26T19:22:07Z',
'confused': 0, 'updated_at': '2024-03-26T19:58:24Z',
'heart': 0, 'closed_at': None,
'rocket': 0, 'author_association': 'NONE',
'eyes': 0}, 'active_lock_reason': None,
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5801 'draft': False,
8/timeline', 'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul
'performed_via_github_app': None, ls/58017',
'state_reason': None}, 'html_url': 'https://github.com/pandas-dev/pandas/pull/58017',
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58017', 'diff_url': 'https://github.com/pandas-dev/pandas/pull/58017.diff',
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'patch_url': 'https://github.com/pandas-dev/pandas/pull/58017.patch',
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58017/ 'merged_at': None},
labels{/name}', 'body': '- [x] closes #57277\r\n- [N/A] [Tests added and passed](https://pa
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5801 ndas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writin
7/comments', g-tests) if fixing a bug or adding a new feature\r\n- [x] All [code checks pa
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58017/ ssed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_code
events', base.html#pre-commit).\r\n- [N/A] Added [type annotations](https://pandas.pyd
'html_url': 'https://github.com/pandas-dev/pandas/pull/58017', ata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to
'id': 2209129013, new arguments/methods/functions.\r\n- [N/A] Added an entry in the latest `do
'node_id': 'PR_kwDOAA0YD85q1sNi', c/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new featur
'number': 58017, e.\r\n',
'title': 'Docs: Add note about exception for integer slices with float indi 'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue
s/58017/reactions', 'color': 'a10c02',
'total_count': 0, 'default': False,
'+1': 0, 'description': 'Memory or execution speed performance'},
'-1': 0, {'id': 1218227310,
'laugh': 0, 'node_id': 'MDU6TGFiZWwxMjE4MjI3MzEw',
'hooray': 0, 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Index',
'confused': 0, 'name': 'Index',
'heart': 0, 'color': 'e99695',
'rocket': 0, 'default': False,
'eyes': 0}, 'description': 'Related to the Index class or subclasses'}],
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5801 'state': 'open',
7/timeline', 'locked': False,
'performed_via_github_app': None, 'assignee': None,
'state_reason': None}, 'assignees': [],
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58016', 'milestone': None,
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'comments': 0,
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58016/ 'created_at': '2024-03-26T18:09:17Z',
labels{/name}', 'updated_at': '2024-03-27T01:52:35Z',
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5801 'closed_at': None,
6/comments', 'author_association': 'MEMBER',
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58016/ 'active_lock_reason': None,
events', 'draft': False,
'html_url': 'https://github.com/pandas-dev/pandas/pull/58016', 'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul
'id': 2208971557, ls/58016',
'node_id': 'PR_kwDOAA0YD85q1JTW', 'html_url': 'https://github.com/pandas-dev/pandas/pull/58016',
'number': 58016, 'diff_url': 'https://github.com/pandas-dev/pandas/pull/58016.diff',
'title': 'PERF: Allow np.integer Series/Index to convert to RangeIndex', 'patch_url': 'https://github.com/pandas-dev/pandas/pull/58016.patch',
'user': {'login': 'mroeschke', 'merged_at': None},
'id': 10647082, 'body': 'Discovered in https://github.com/pandas-dev/pandas/pull/57441',
'node_id': 'MDQ6VXNlcjEwNjQ3MDgy', 'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue
'avatar_url': 'https://avatars.githubusercontent.com/u/10647082?v=4', s/58016/reactions',
'gravatar_id': '', 'total_count': 0,
'url': 'https://api.github.com/users/mroeschke', '+1': 0,
'html_url': 'https://github.com/mroeschke', '-1': 0,
'followers_url': 'https://api.github.com/users/mroeschke/followers', 'laugh': 0,
'following_url': 'https://api.github.com/users/mroeschke/following{/othe 'hooray': 0,
r_user}', 'confused': 0,
'gists_url': 'https://api.github.com/users/mroeschke/gists{/gist_id}', 'heart': 0,
'starred_url': 'https://api.github.com/users/mroeschke/starred{/owner}{/re 'rocket': 0,
po}', 'eyes': 0},
'subscriptions_url': 'https://api.github.com/users/mroeschke/subscription 'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5801
s', 6/timeline',
'organizations_url': 'https://api.github.com/users/mroeschke/orgs', 'performed_via_github_app': None,
'repos_url': 'https://api.github.com/users/mroeschke/repos', 'state_reason': None},
'events_url': 'https://api.github.com/users/mroeschke/events{/privacy}', {'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58015',
'received_events_url': 'https://api.github.com/users/mroeschke/received_ev 'repository_url': 'https://api.github.com/repos/pandas-dev/pandas',
ents', 'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58015/
'type': 'User', labels{/name}',
'site_admin': False}, 'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5801
'labels': [{'id': 8935311, 5/comments',
'node_id': 'MDU6TGFiZWw4OTM1MzEx', 'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58015/
'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Performanc events',
e', 'html_url': 'https://github.com/pandas-dev/pandas/issues/58015',
'name': 'Performance', 'id': 2208961335,
'node_id': 'I_kwDOAA0YD86DqhM3', 'color': '547c03',
'number': 58015, 'default': False,
'title': 'BUG: Behaviour of sum/mean on sparse boolean arrays changed betwe 'description': 'sum, mean, min, max, etc.'}],
en 1.5.3 and pandas 2.2', 'state': 'open',
'user': {'login': 'CompRhys', 'locked': False,
'id': 26601751, 'assignee': {'login': 'dontgoto',
'node_id': 'MDQ6VXNlcjI2NjAxNzUx', 'id': 6079615,
'avatar_url': 'https://avatars.githubusercontent.com/u/26601751?v=4', 'node_id': 'MDQ6VXNlcjYwNzk2MTU=',
'gravatar_id': '', 'avatar_url': 'https://avatars.githubusercontent.com/u/6079615?v=4',
'url': 'https://api.github.com/users/CompRhys', 'gravatar_id': '',
'html_url': 'https://github.com/CompRhys', 'url': 'https://api.github.com/users/dontgoto',
'followers_url': 'https://api.github.com/users/CompRhys/followers', 'html_url': 'https://github.com/dontgoto',
'following_url': 'https://api.github.com/users/CompRhys/following{/other_u 'followers_url': 'https://api.github.com/users/dontgoto/followers',
ser}', 'following_url': 'https://api.github.com/users/dontgoto/following{/other_u
'gists_url': 'https://api.github.com/users/CompRhys/gists{/gist_id}', ser}',
'starred_url': 'https://api.github.com/users/CompRhys/starred{/owner}{/rep 'gists_url': 'https://api.github.com/users/dontgoto/gists{/gist_id}',
o}', 'starred_url': 'https://api.github.com/users/dontgoto/starred{/owner}{/rep
'subscriptions_url': 'https://api.github.com/users/CompRhys/subscription o}',
s', 'subscriptions_url': 'https://api.github.com/users/dontgoto/subscription
'organizations_url': 'https://api.github.com/users/CompRhys/orgs', s',
'repos_url': 'https://api.github.com/users/CompRhys/repos', 'organizations_url': 'https://api.github.com/users/dontgoto/orgs',
'events_url': 'https://api.github.com/users/CompRhys/events{/privacy}', 'repos_url': 'https://api.github.com/users/dontgoto/repos',
'received_events_url': 'https://api.github.com/users/CompRhys/received_eve 'events_url': 'https://api.github.com/users/dontgoto/events{/privacy}',
nts', 'received_events_url': 'https://api.github.com/users/dontgoto/received_eve
'type': 'User', nts',
'site_admin': False}, 'type': 'User',
'labels': [{'id': 76811, 'site_admin': False},
'node_id': 'MDU6TGFiZWw3NjgxMQ==', 'assignees': [{'login': 'dontgoto',
'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Bug', 'id': 6079615,
'name': 'Bug', 'node_id': 'MDQ6VXNlcjYwNzk2MTU=',
'color': 'e10c02', 'avatar_url': 'https://avatars.githubusercontent.com/u/6079615?v=4',
'default': False, 'gravatar_id': '',
'description': None}, 'url': 'https://api.github.com/users/dontgoto',
{'id': 31404521, 'html_url': 'https://github.com/dontgoto',
'node_id': 'MDU6TGFiZWwzMTQwNDUyMQ==', 'followers_url': 'https://api.github.com/users/dontgoto/followers',
'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Dtype%20Con 'following_url': 'https://api.github.com/users/dontgoto/following{/othe
versions', r_user}',
'name': 'Dtype Conversions', 'gists_url': 'https://api.github.com/users/dontgoto/gists{/gist_id}',
'color': 'e102d8', 'starred_url': 'https://api.github.com/users/dontgoto/starred{/owner}{/re
'default': False, po}',
'description': 'Unexpected or buggy dtype conversions'}, 'subscriptions_url': 'https://api.github.com/users/dontgoto/subscription
{'id': 849023693, s',
'node_id': 'MDU6TGFiZWw4NDkwMjM2OTM=', 'organizations_url': 'https://api.github.com/users/dontgoto/orgs',
'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/ExtensionAr 'repos_url': 'https://api.github.com/users/dontgoto/repos',
ray', 'events_url': 'https://api.github.com/users/dontgoto/events{/privacy}',
'name': 'ExtensionArray', 'received_events_url': 'https://api.github.com/users/dontgoto/received_ev
'color': '6138b5', ents',
'default': False, 'type': 'User',
'description': 'Extending pandas with custom dtypes or arrays.'}, 'site_admin': False}],
{'id': 2365504383, 'milestone': None,
'node_id': 'MDU6TGFiZWwyMzY1NTA0Mzgz', 'comments': 4,
'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Reduction%2 'created_at': '2024-03-26T18:03:59Z',
0Operations', 'updated_at': '2024-03-27T09:42:37Z',
'name': 'Reduction Operations', 'closed_at': None,
'author_association': 'NONE', 'title': 'Potential regression induced by "CLN: Enforce deprecation of argm
'active_lock_reason': None, in/max and idxmin/max with NA values"',
'body': "### Pandas version checks\r\n\r\n- [X] I have checked that this is 'user': {'login': 'DeaMariaLeon',
sue has not already been reported.\r\n\r\n- [X] I have confirmed this bug exi 'id': 11835246,
sts on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.htm 'node_id': 'MDQ6VXNlcjExODM1MjQ2',
l) of pandas.\r\n\r\n- [ ] I have confirmed this bug exists on the [main bran 'avatar_url': 'https://avatars.githubusercontent.com/u/11835246?v=4',
ch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installin 'gravatar_id': '',
g-the-development-version-of-pandas) of pandas.\r\n\r\n\r\n### Reproducible E 'url': 'https://api.github.com/users/DeaMariaLeon',
xample\r\n\r\n```python\r\n>>> import pandas as pd\r\n>>> import numpy as np\ 'html_url': 'https://github.com/DeaMariaLeon',
r\n>>> pd.__version__\r\n'2.2.1'\r\n>>> a = pd.DataFrame(np.random.randint(2, 'followers_url': 'https://api.github.com/users/DeaMariaLeon/followers',
size=(3,4))).astype(pd.SparseDtype(int, fill_value=0))\r\n>>> a\r\n 0 1 2 'following_url': 'https://api.github.com/users/DeaMariaLeon/following{/oth
3\r\n0 0 0 1 0\r\n1 0 1 0 1\r\n2 0 1 1 0\r\ndtype: Sparse[int64, er_user}',
0]\r\n>>> (a>0).sum(axis=1)\r\n0 True\r\n1 True\r\n2 True\r\ndtype: 'gists_url': 'https://api.github.com/users/DeaMariaLeon/gists{/gist_id}',
Sparse[bool, False]\r\n>>> b = pd.DataFrame(np.random.randint(2, siz 'starred_url': 'https://api.github.com/users/DeaMariaLeon/starred{/owne
e=(3,4)))\r\n>>> (b>0).sum(axis=1)\r\n0 3\r\n1 4\r\n2 2\r\ndtype: in r}{/repo}',
t64\r\n```\r\n\r\n```python\r\n>>> import pandas as pd\r\n>>> import numpy as 'subscriptions_url': 'https://api.github.com/users/DeaMariaLeon/subscripti
np\r\n>>> pd.__version__\r\n'1.5.3'\r\n>>> a = pd.DataFrame(np.random.randin ons',
t(2, size=(3,4))).astype(pd.SparseDtype(int, fill_value=0))\r\n>>> a\r\n 0 'organizations_url': 'https://api.github.com/users/DeaMariaLeon/orgs',
1 2 3\r\n0 1 1 0 0\r\n1 0 0 1 0\r\n2 0 0 1 1\r\n>>> (a>0).sum(a 'repos_url': 'https://api.github.com/users/DeaMariaLeon/repos',
xis=1)\r\n0 2\r\n1 1\r\n2 2\r\ndtype: int64\r\n>>> b = pd.DataFram 'events_url': 'https://api.github.com/users/DeaMariaLeon/events{/privac
e(np.random.randint(2, size=(3,4)))\r\n>>> (b>0).sum(axis=1)\r\n0 1\r\n1 y}',
4\r\n2 1\r\ndtype: int64\r\n```\r\n```\r\n\r\n\r\n### Issue Description\r\ 'received_events_url': 'https://api.github.com/users/DeaMariaLeon/receive
n\r\nThe sum of a sparse boolean array is sparse boolean rather than int.\r\ d_events',
n\r\n### Expected Behavior\r\n\r\nI would expect the sum of a sparse boolean 'type': 'User',
array to be an int in order to match the behavior on a dense array.\r\n\r\ 'site_admin': False},
n### Installed Versions\r\n\r\nthis issue is observed swapping from 1.5.3 to 'labels': [{'id': 2822342,
2.2.1", 'node_id': 'MDU6TGFiZWwyODIyMzQy',
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Missing-dat
s/58015/reactions', a',
'total_count': 0, 'name': 'Missing-data',
'+1': 0, 'color': 'd7e102',
'-1': 0, 'default': False,
'laugh': 0, 'description': 'np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate'},
'hooray': 0, {'id': 8935311,
'confused': 0, 'node_id': 'MDU6TGFiZWw4OTM1MzEx',
'heart': 0, 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Performanc
'rocket': 0, e',
'eyes': 0}, 'name': 'Performance',
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5801 'color': 'a10c02',
5/timeline', 'default': False,
'performed_via_github_app': None, 'description': 'Memory or execution speed performance'},
'state_reason': None}, {'id': 32815646,
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58013', 'node_id': 'MDU6TGFiZWwzMjgxNTY0Ng==',
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Regressio
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58013/ n',
labels{/name}', 'name': 'Regression',
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5801 'color': 'e11d21',
3/comments', 'default': False,
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58013/ 'description': 'Functionality that used to work in a prior pandas versio
events', n'},
'html_url': 'https://github.com/pandas-dev/pandas/issues/58013', {'id': 732775912,
'id': 2208516917, 'node_id': 'MDU6TGFiZWw3MzI3NzU5MTI=',
'node_id': 'I_kwDOAA0YD86Do0s1', 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Benchmark',
'number': 58013, 'name': 'Benchmark',
'color': 'ae68cc', 'heart': 0,
'default': False, 'rocket': 0,
'description': 'Performance (ASV) benchmarks'}, 'eyes': 0},
{'id': 2365504383, 'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5801
'node_id': 'MDU6TGFiZWwyMzY1NTA0Mzgz', 3/timeline',
'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Reduction%2 'performed_via_github_app': None,
0Operations', 'state_reason': None},
'name': 'Reduction Operations', {'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58012',
'color': '547c03', 'repository_url': 'https://api.github.com/repos/pandas-dev/pandas',
'default': False, 'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58012/
'description': 'sum, mean, min, max, etc.'}], labels{/name}',
'state': 'open', 'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5801
'locked': False, 2/comments',
'assignee': None, 'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58012/
'assignees': [], events',
'milestone': None, 'html_url': 'https://github.com/pandas-dev/pandas/pull/58012',
'comments': 1, 'id': 2207779364,
'created_at': '2024-03-26T15:04:29Z', 'node_id': 'PR_kwDOAA0YD85qxB2F',
'updated_at': '2024-03-26T21:49:51Z', 'number': 58012,
'closed_at': None, 'title': 'Add tests for transform sum with series',
'author_association': 'MEMBER', 'user': {'login': 'undermyumbrella1',
'active_lock_reason': None, 'id': 120079323,
'body': 'PR #57971\r\n\r\nIf it is expected please ignore this issue.\r\n\ 'node_id': 'U_kgDOByhD2w',
r\n "`series_methods.NanOps.time_func` (Python) with N=1000, dtype=\'int64\', 'avatar_url': 'https://avatars.githubusercontent.com/u/120079323?v=4',
func=\'argmax\'": "http://57.128.112.95:5000/compare/benchmarks/0660238e60827 'gravatar_id': '',
0fe8000d90917fab443...066023bb74387b2880001e8c3a13bc9a",\r\n "`serie 'url': 'https://api.github.com/users/undermyumbrella1',
s_methods.NanOps.time_func` (Python) with N=1000, dtype=\'int32\', func=\'arg 'html_url': 'https://github.com/undermyumbrella1',
max\'": "http://57.128.112.95:5000/compare/benchmarks/0660238e5f92703b8000518 'followers_url': 'https://api.github.com/users/undermyumbrella1/follower
426c1e358...066023bb739a770480009c84952aeeef",\r\n "`series_methods.Na s',
nOps.time_func` (Python) with N=1000, dtype=\'float64\', func=\'argmax\'": "h 'following_url': 'https://api.github.com/users/undermyumbrella1/followin
ttp://57.128.112.95:5000/compare/benchmarks/0660238e6123788c800045f9fafc011 g{/other_user}',
0...066023bb74d0713e8000b7a515b8b450",\r\n "`series_methods.NanOps.tim 'gists_url': 'https://api.github.com/users/undermyumbrella1/gists{/gist_i
e_func` (Python) with N=1000000, dtype=\'float64\', func=\'argmax\'": "htt d}',
p://57.128.112.95:5000/compare/benchmarks/0660238e642e791e80009e362f432db 'starred_url': 'https://api.github.com/users/undermyumbrella1/starred{/own
3...066023bb77a3764180003374cf6f549e",\r\n "`series_methods.NanOps.tim er}{/repo}',
e_func` (Python) with N=1000000, dtype=\'int32\', func=\'argmax\'": "http://5 'subscriptions_url': 'https://api.github.com/users/undermyumbrella1/subscr
7.128.112.95:5000/compare/benchmarks/0660238e62897b5a8000f233376be753...06602 iptions',
3bb7642748e800066e39b4e1ef1",\r\n "`series_methods.NanOps.time_func` 'organizations_url': 'https://api.github.com/users/undermyumbrella1/orgs',
(Python) with N=1000000, dtype=\'int8\', func=\'argmax\'": "http://57.128.11 'repos_url': 'https://api.github.com/users/undermyumbrella1/repos',
2.95:5000/compare/benchmarks/0660238e61dd7d9d80001bbda6f52684...066023bb759c7 'events_url': 'https://api.github.com/users/undermyumbrella1/events{/priva
44480000ea47833c954",\r\n "`series_methods.NanOps.time_func` (Python) cy}',
with N=1000, dtype=\'int8\', func=\'argmax\'": "http://57.128.112.95:5000/com 'received_events_url': 'https://api.github.com/users/undermyumbrella1/rece
pare/benchmarks/0660238e5ee8721780008aed6e250c64...066023bb72f377158000ee04eb ived_events',
8137ee"\r\n\r\n@rhshadrach \r\n\r\n![Screenshot 2024-03-26 at 16 03 17](http 'type': 'User',
s://github.com/pandas-dev/pandas/assets/11835246/0415f2f9-f3ef-4419-b414-9a8c 'site_admin': False},
9f58ba67)\r\n', 'labels': [{'id': 127685,
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'node_id': 'MDU6TGFiZWwxMjc2ODU=',
s/58013/reactions', 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Testing',
'total_count': 0, 'name': 'Testing',
'+1': 0, 'color': 'C4A000',
'-1': 0, 'default': False,
'laugh': 0, 'description': 'pandas testing functions or related to the test suite'}],
'hooray': 0, 'state': 'open',
'confused': 0, 'locked': False,
'assignee': None, 'node_id': 'MDQ6VXNlcjgwNzg5Njg=',
'assignees': [], 'avatar_url': 'https://avatars.githubusercontent.com/u/8078968?v=4',
'milestone': None, 'gravatar_id': '',
'comments': 0, 'url': 'https://api.github.com/users/jbrockmendel',
'created_at': '2024-03-26T09:56:19Z', 'html_url': 'https://github.com/jbrockmendel',
'updated_at': '2024-03-26T17:13:21Z', 'followers_url': 'https://api.github.com/users/jbrockmendel/followers',
'closed_at': None, 'following_url': 'https://api.github.com/users/jbrockmendel/following{/oth
'author_association': 'NONE', er_user}',
'active_lock_reason': None, 'gists_url': 'https://api.github.com/users/jbrockmendel/gists{/gist_id}',
'draft': False, 'starred_url': 'https://api.github.com/users/jbrockmendel/starred{/owne
'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul r}{/repo}',
ls/58012', 'subscriptions_url': 'https://api.github.com/users/jbrockmendel/subscripti
'html_url': 'https://github.com/pandas-dev/pandas/pull/58012', ons',
'diff_url': 'https://github.com/pandas-dev/pandas/pull/58012.diff', 'organizations_url': 'https://api.github.com/users/jbrockmendel/orgs',
'patch_url': 'https://github.com/pandas-dev/pandas/pull/58012.patch', 'repos_url': 'https://api.github.com/users/jbrockmendel/repos',
'merged_at': None}, 'events_url': 'https://api.github.com/users/jbrockmendel/events{/privac
'body': '- [x] closes #37093 \r\n- [x] [Tests added and passed](https://pan y}',
das.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writin 'received_events_url': 'https://api.github.com/users/jbrockmendel/receive
g-tests) if fixing a bug or adding a new feature\r\n- [x] All [code checks pa d_events',
ssed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_code 'type': 'User',
base.html#pre-commit).\r\n- [x] Added [type annotations](https://pandas.pydat 'site_admin': False},
a.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to n 'labels': [{'id': 211029535,
ew arguments/methods/functions.\r\n- [x] Added an entry in the latest `doc/so 'node_id': 'MDU6TGFiZWwyMTEwMjk1MzU=',
urce/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.\r\n', 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Clean',
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'name': 'Clean',
s/58012/reactions', 'color': '207de5',
'total_count': 0, 'default': False,
'+1': 0, 'description': None}],
'-1': 0, 'state': 'open',
'laugh': 0, 'locked': False,
'hooray': 0, 'assignee': None,
'confused': 0, 'assignees': [],
'heart': 0, 'milestone': None,
'rocket': 0, 'comments': 0,
'eyes': 0}, 'created_at': '2024-03-26T02:37:10Z',
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5801 'updated_at': '2024-03-26T17:48:13Z',
2/timeline', 'closed_at': None,
'performed_via_github_app': None, 'author_association': 'MEMBER',
'state_reason': None}, 'active_lock_reason': None,
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58011', 'draft': False,
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58011/ ls/58011',
labels{/name}', 'html_url': 'https://github.com/pandas-dev/pandas/pull/58011',
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5801 'diff_url': 'https://github.com/pandas-dev/pandas/pull/58011.diff',
1/comments', 'patch_url': 'https://github.com/pandas-dev/pandas/pull/58011.patch',
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58011/ 'merged_at': None},
events', 'body': '- [ ] closes #xxxx (Replace xxxx with the GitHub issue number)\r\
'html_url': 'https://github.com/pandas-dev/pandas/pull/58011', n- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/dev
'id': 2207115461, elopment/contributing_codebase.html#writing-tests) if fixing a bug or adding
'node_id': 'PR_kwDOAA0YD85quv0H', a new feature\r\n- [ ] All [code checks passed](https://pandas.pydata.org/pan
'number': 58011, das-docs/dev/development/contributing_codebase.html#pre-commit).\r\n- [ ] Add
'title': 'DEPR: enforce deprecation of non-standard argument to take', ed [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/c
'user': {'login': 'jbrockmendel', ontributing_codebase.html#type-hints) to new arguments/methods/functions.\r\
'id': 8078968, n- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if
fixing a bug or adding a new feature.\r\n', 'state': 'open',
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'locked': False,
s/58011/reactions', 'assignee': None,
'total_count': 0, 'assignees': [],
'+1': 0, 'milestone': {'url': 'https://api.github.com/repos/pandas-dev/pandas/milest
'-1': 0, ones/117',
'laugh': 0, 'html_url': 'https://github.com/pandas-dev/pandas/milestone/117',
'hooray': 0, 'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/milestones/1
'confused': 0, 17/labels',
'heart': 0, 'id': 10539704,
'rocket': 0, 'node_id': 'MI_kwDOAA0YD84AoNK4',
'eyes': 0}, 'number': 117,
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5801 'title': '2.2.2',
1/timeline', 'description': 'on-merge: backport to 2.2.x',
'performed_via_github_app': None, 'creator': {'login': 'lithomas1',
'state_reason': None}, 'id': 47963215,
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58008', 'node_id': 'MDQ6VXNlcjQ3OTYzMjE1',
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'avatar_url': 'https://avatars.githubusercontent.com/u/47963215?v=4',
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58008/ 'gravatar_id': '',
labels{/name}', 'url': 'https://api.github.com/users/lithomas1',
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5800 'html_url': 'https://github.com/lithomas1',
8/comments', 'followers_url': 'https://api.github.com/users/lithomas1/followers',
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58008/ 'following_url': 'https://api.github.com/users/lithomas1/following{/othe
events', r_user}',
'html_url': 'https://github.com/pandas-dev/pandas/pull/58008', 'gists_url': 'https://api.github.com/users/lithomas1/gists{/gist_id}',
'id': 2207069242, 'starred_url': 'https://api.github.com/users/lithomas1/starred{/owner}{/r
'node_id': 'PR_kwDOAA0YD85qumKL', epo}',
'number': 58008, 'subscriptions_url': 'https://api.github.com/users/lithomas1/subscription
'title': 'Backport PR #57553 on branch 2.2.x (API: avoid passing Manager to s',
subclass init)', 'organizations_url': 'https://api.github.com/users/lithomas1/orgs',
'user': {'login': 'jbrockmendel', 'repos_url': 'https://api.github.com/users/lithomas1/repos',
'id': 8078968, 'events_url': 'https://api.github.com/users/lithomas1/events{/privacy}',
'node_id': 'MDQ6VXNlcjgwNzg5Njg=', 'received_events_url': 'https://api.github.com/users/lithomas1/received_e
'avatar_url': 'https://avatars.githubusercontent.com/u/8078968?v=4', vents',
'gravatar_id': '', 'type': 'User',
'url': 'https://api.github.com/users/jbrockmendel', 'site_admin': False},
'html_url': 'https://github.com/jbrockmendel', 'open_issues': 44,
'followers_url': 'https://api.github.com/users/jbrockmendel/followers', 'closed_issues': 47,
'following_url': 'https://api.github.com/users/jbrockmendel/following{/oth 'state': 'open',
er_user}', 'created_at': '2024-02-10T23:53:00Z',
'gists_url': 'https://api.github.com/users/jbrockmendel/gists{/gist_id}', 'updated_at': '2024-03-26T21:04:14Z',
'starred_url': 'https://api.github.com/users/jbrockmendel/starred{/owne 'due_on': None,
r}{/repo}', 'closed_at': None},
'subscriptions_url': 'https://api.github.com/users/jbrockmendel/subscripti 'comments': 1,
ons', 'created_at': '2024-03-26T01:49:10Z',
'organizations_url': 'https://api.github.com/users/jbrockmendel/orgs', 'updated_at': '2024-03-26T17:57:29Z',
'repos_url': 'https://api.github.com/users/jbrockmendel/repos', 'closed_at': None,
'events_url': 'https://api.github.com/users/jbrockmendel/events{/privac 'author_association': 'MEMBER',
y}', 'active_lock_reason': None,
'received_events_url': 'https://api.github.com/users/jbrockmendel/receive 'draft': False,
d_events', 'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul
'type': 'User', ls/58008',
'site_admin': False}, 'html_url': 'https://github.com/pandas-dev/pandas/pull/58008',
'labels': [], 'diff_url': 'https://github.com/pandas-dev/pandas/pull/58008.diff',
'patch_url': 'https://github.com/pandas-dev/pandas/pull/58008.patch', s',
'merged_at': None}, 'organizations_url': 'https://api.github.com/users/mroeschke/orgs',
'body': '- [ ] closes #xxxx (Replace xxxx with the GitHub issue number)\r\ 'repos_url': 'https://api.github.com/users/mroeschke/repos',
n- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/dev 'events_url': 'https://api.github.com/users/mroeschke/events{/privacy}',
elopment/contributing_codebase.html#writing-tests) if fixing a bug or adding 'received_events_url': 'https://api.github.com/users/mroeschke/received_ev
a new feature\r\n- [ ] All [code checks passed](https://pandas.pydata.org/pan ents',
das-docs/dev/development/contributing_codebase.html#pre-commit).\r\n- [ ] Add 'type': 'User',
ed [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/c 'site_admin': False},
ontributing_codebase.html#type-hints) to new arguments/methods/functions.\r\ 'labels': [{'id': 2085877452,
n- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if 'node_id': 'MDU6TGFiZWwyMDg1ODc3NDUy',
fixing a bug or adding a new feature.\r\n', 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Copy%20/%20
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue view%20semantics',
s/58008/reactions', 'name': 'Copy / view semantics',
'total_count': 0, 'color': '70e5ca',
'+1': 0, 'default': False,
'-1': 0, 'description': ''}],
'laugh': 0, 'state': 'open',
'hooray': 0, 'locked': False,
'confused': 0, 'assignee': None,
'heart': 0, 'assignees': [],
'rocket': 0, 'milestone': {'url': 'https://api.github.com/repos/pandas-dev/pandas/milest
'eyes': 0}, ones/102',
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5800 'html_url': 'https://github.com/pandas-dev/pandas/milestone/102',
8/timeline', 'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/milestones/1
'performed_via_github_app': None, 02/labels',
'state_reason': None}, 'id': 9021906,
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58007', 'node_id': 'MI_kwDOAA0YD84AianS',
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'number': 102,
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58007/ 'title': '3.0',
labels{/name}', 'description': '',
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5800 'creator': {'login': 'jbrockmendel',
7/comments', 'id': 8078968,
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58007/ 'node_id': 'MDQ6VXNlcjgwNzg5Njg=',
events', 'avatar_url': 'https://avatars.githubusercontent.com/u/8078968?v=4',
'html_url': 'https://github.com/pandas-dev/pandas/issues/58007', 'gravatar_id': '',
'id': 2206966549, 'url': 'https://api.github.com/users/jbrockmendel',
'node_id': 'I_kwDOAA0YD86Di6MV', 'html_url': 'https://github.com/jbrockmendel',
'number': 58007, 'followers_url': 'https://api.github.com/users/jbrockmendel/followers',
'title': 'API: Make `Series.array` a read-only NumpyExtensionEA when applic 'following_url': 'https://api.github.com/users/jbrockmendel/following{/ot
able', her_user}',
'user': {'login': 'mroeschke', 'gists_url': 'https://api.github.com/users/jbrockmendel/gists{/gist_id}',
'id': 10647082, 'starred_url': 'https://api.github.com/users/jbrockmendel/starred{/owne
'node_id': 'MDQ6VXNlcjEwNjQ3MDgy', r}{/repo}',
'avatar_url': 'https://avatars.githubusercontent.com/u/10647082?v=4', 'subscriptions_url': 'https://api.github.com/users/jbrockmendel/subscript
'gravatar_id': '', ions',
'url': 'https://api.github.com/users/mroeschke', 'organizations_url': 'https://api.github.com/users/jbrockmendel/orgs',
'html_url': 'https://github.com/mroeschke', 'repos_url': 'https://api.github.com/users/jbrockmendel/repos',
'followers_url': 'https://api.github.com/users/mroeschke/followers', 'events_url': 'https://api.github.com/users/jbrockmendel/events{/privac
'following_url': 'https://api.github.com/users/mroeschke/following{/othe y}',
r_user}', 'received_events_url': 'https://api.github.com/users/jbrockmendel/receive
'gists_url': 'https://api.github.com/users/mroeschke/gists{/gist_id}', d_events',
'starred_url': 'https://api.github.com/users/mroeschke/starred{/owner}{/re 'type': 'User',
po}', 'site_admin': False},
'subscriptions_url': 'https://api.github.com/users/mroeschke/subscription 'open_issues': 51,
'closed_issues': 481, 'gravatar_id': '',
'state': 'open', 'url': 'https://api.github.com/users/natmokval',
'created_at': '2023-02-08T18:16:49Z', 'html_url': 'https://github.com/natmokval',
'updated_at': '2024-03-27T03:43:05Z', 'followers_url': 'https://api.github.com/users/natmokval/followers',
'due_on': '2024-04-01T07:00:00Z', 'following_url': 'https://api.github.com/users/natmokval/following{/othe
'closed_at': None}, r_user}',
'comments': 2, 'gists_url': 'https://api.github.com/users/natmokval/gists{/gist_id}',
'created_at': '2024-03-26T00:12:58Z', 'starred_url': 'https://api.github.com/users/natmokval/starred{/owner}{/re
'updated_at': '2024-03-26T21:20:18Z', po}',
'closed_at': None, 'subscriptions_url': 'https://api.github.com/users/natmokval/subscription
'author_association': 'MEMBER', s',
'active_lock_reason': None, 'organizations_url': 'https://api.github.com/users/natmokval/orgs',
'body': "Mutating `Series.values` has been disabled for 3.0 with CoW becomi 'repos_url': 'https://api.github.com/users/natmokval/repos',
ng the default behavior, but `Series.array` is still mutable.\r\n\r\n```pytho 'events_url': 'https://api.github.com/users/natmokval/events{/privacy}',
n\r\nIn [1]: In [1]: import pandas as pd\r\n ...: \r\n ...: In [2]: s = p 'received_events_url': 'https://api.github.com/users/natmokval/received_ev
d.Series([1, 2, pd.NA])\r\n ...: \r\n ...: In [3]: a = s.array\r\n\r\nIn ents',
[2]: a[:2] = 3\r\n\r\nIn [3]: a\r\nOut[3]: \r\n<NumpyExtensionArray>\r\n[3, 'type': 'User',
3, <NA>]\r\nLength: 3, dtype: object\r\n\r\nIn [4]: s\r\nOut[4]: \r\n0 'site_admin': False},
3\r\n1 3\r\n2 <NA>\r\ndtype: object\r\n```\r\n\r\nThere's a comment 'labels': [{'id': 1218227310,
in `pandas/core/internals/blocks.py` in `external_values` to make backing Ext 'node_id': 'MDU6TGFiZWwxMjE4MjI3MzEw',
ensionArrays read-only", 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Index',
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'name': 'Index',
s/58007/reactions', 'color': 'e99695',
'total_count': 0, 'default': False,
'+1': 0, 'description': 'Related to the Index class or subclasses'},
'-1': 0, {'id': 2365504383,
'laugh': 0, 'node_id': 'MDU6TGFiZWwyMzY1NTA0Mzgz',
'hooray': 0, 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Reduction%2
'confused': 0, 0Operations',
'heart': 0, 'name': 'Reduction Operations',
'rocket': 0, 'color': '547c03',
'eyes': 0}, 'default': False,
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5800 'description': 'sum, mean, min, max, etc.'}],
7/timeline', 'state': 'open',
'performed_via_github_app': None, 'locked': False,
'state_reason': None}, 'assignee': None,
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58006', 'assignees': [],
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'milestone': None,
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58006/ 'comments': 0,
labels{/name}', 'created_at': '2024-03-25T22:56:32Z',
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5800 'updated_at': '2024-03-27T15:03:03Z',
6/comments', 'closed_at': None,
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58006/ 'author_association': 'CONTRIBUTOR',
events', 'active_lock_reason': None,
'html_url': 'https://github.com/pandas-dev/pandas/pull/58006', 'draft': False,
'id': 2206883417, 'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul
'node_id': 'PR_kwDOAA0YD85qt9x1', ls/58006',
'number': 58006, 'html_url': 'https://github.com/pandas-dev/pandas/pull/58006',
'title': 'CLN: remove unnecessary check `needs_i8_conversion` if Index subc 'diff_url': 'https://github.com/pandas-dev/pandas/pull/58006.diff',
lass does not support `any` or `all`', 'patch_url': 'https://github.com/pandas-dev/pandas/pull/58006.patch',
'user': {'login': 'natmokval', 'merged_at': None},
'id': 91160475, 'body': 'xref #54566\r\n\r\nremoved unnecessary check needs_i8_conversion i
'node_id': 'MDQ6VXNlcjkxMTYwNDc1', f Index subclass does not support any or all. ',
'avatar_url': 'https://avatars.githubusercontent.com/u/91160475?v=4', 'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue
s/58006/reactions', 'default': False,
'total_count': 0, 'description': None},
'+1': 0, {'id': 2822342,
'-1': 0, 'node_id': 'MDU6TGFiZWwyODIyMzQy',
'laugh': 0, 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Missing-dat
'hooray': 0, a',
'confused': 0, 'name': 'Missing-data',
'heart': 0, 'color': 'd7e102',
'rocket': 0, 'default': False,
'eyes': 0}, 'description': 'np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate'},
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5800 {'id': 849023693,
6/timeline', 'node_id': 'MDU6TGFiZWw4NDkwMjM2OTM=',
'performed_via_github_app': None, 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/ExtensionAr
'state_reason': None}, ray',
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58001', 'name': 'ExtensionArray',
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'color': '6138b5',
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58001/ 'default': False,
labels{/name}', 'description': 'Extending pandas with custom dtypes or arrays.'}],
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5800 'state': 'open',
1/comments', 'locked': False,
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/58001/ 'assignee': {'login': 'rhshadrach',
events', 'id': 45562402,
'html_url': 'https://github.com/pandas-dev/pandas/issues/58001', 'node_id': 'MDQ6VXNlcjQ1NTYyNDAy',
'id': 2206663607, 'avatar_url': 'https://avatars.githubusercontent.com/u/45562402?v=4',
'node_id': 'I_kwDOAA0YD86DhwO3', 'gravatar_id': '',
'number': 58001, 'url': 'https://api.github.com/users/rhshadrach',
'title': 'BUG: Implement `fillna(..., limit=x)` for EAs', 'html_url': 'https://github.com/rhshadrach',
'user': {'login': 'rhshadrach', 'followers_url': 'https://api.github.com/users/rhshadrach/followers',
'id': 45562402, 'following_url': 'https://api.github.com/users/rhshadrach/following{/othe
'node_id': 'MDQ6VXNlcjQ1NTYyNDAy', r_user}',
'avatar_url': 'https://avatars.githubusercontent.com/u/45562402?v=4', 'gists_url': 'https://api.github.com/users/rhshadrach/gists{/gist_id}',
'gravatar_id': '', 'starred_url': 'https://api.github.com/users/rhshadrach/starred{/owner}{/r
'url': 'https://api.github.com/users/rhshadrach', epo}',
'html_url': 'https://github.com/rhshadrach', 'subscriptions_url': 'https://api.github.com/users/rhshadrach/subscription
'followers_url': 'https://api.github.com/users/rhshadrach/followers', s',
'following_url': 'https://api.github.com/users/rhshadrach/following{/othe 'organizations_url': 'https://api.github.com/users/rhshadrach/orgs',
r_user}', 'repos_url': 'https://api.github.com/users/rhshadrach/repos',
'gists_url': 'https://api.github.com/users/rhshadrach/gists{/gist_id}', 'events_url': 'https://api.github.com/users/rhshadrach/events{/privacy}',
'starred_url': 'https://api.github.com/users/rhshadrach/starred{/owner}{/r 'received_events_url': 'https://api.github.com/users/rhshadrach/received_e
epo}', vents',
'subscriptions_url': 'https://api.github.com/users/rhshadrach/subscription 'type': 'User',
s', 'site_admin': False},
'organizations_url': 'https://api.github.com/users/rhshadrach/orgs', 'assignees': [{'login': 'rhshadrach',
'repos_url': 'https://api.github.com/users/rhshadrach/repos', 'id': 45562402,
'events_url': 'https://api.github.com/users/rhshadrach/events{/privacy}', 'node_id': 'MDQ6VXNlcjQ1NTYyNDAy',
'received_events_url': 'https://api.github.com/users/rhshadrach/received_e 'avatar_url': 'https://avatars.githubusercontent.com/u/45562402?v=4',
vents', 'gravatar_id': '',
'type': 'User', 'url': 'https://api.github.com/users/rhshadrach',
'site_admin': False}, 'html_url': 'https://github.com/rhshadrach',
'labels': [{'id': 76811, 'followers_url': 'https://api.github.com/users/rhshadrach/followers',
'node_id': 'MDU6TGFiZWw3NjgxMQ==', 'following_url': 'https://api.github.com/users/rhshadrach/following{/othe
'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Bug', r_user}',
'name': 'Bug', 'gists_url': 'https://api.github.com/users/rhshadrach/gists{/gist_id}',
'color': 'e10c02', 'starred_url': 'https://api.github.com/users/rhshadrach/starred{/owne
r}{/repo}', 'author_association': 'MEMBER',
'subscriptions_url': 'https://api.github.com/users/rhshadrach/subscriptio 'active_lock_reason': None,
ns', 'body': 'Ref #57983\r\n\r\nCurrently `EA.fillna` has a limit argument but i
'organizations_url': 'https://api.github.com/users/rhshadrach/orgs', t is ignored. This was deprecated during 2.x, but that deprecation was remove
'repos_url': 'https://api.github.com/users/rhshadrach/repos', d in the referenced PR. We should keep and implement `limit` here.',
'events_url': 'https://api.github.com/users/rhshadrach/events{/privacy}', 'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue
'received_events_url': 'https://api.github.com/users/rhshadrach/receive s/58001/reactions',
d_events', 'total_count': 0,
'type': 'User', '+1': 0,
'site_admin': False}], '-1': 0,
'milestone': {'url': 'https://api.github.com/repos/pandas-dev/pandas/milest 'laugh': 0,
ones/102', 'hooray': 0,
'html_url': 'https://github.com/pandas-dev/pandas/milestone/102', 'confused': 0,
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/milestones/1 'heart': 0,
02/labels', 'rocket': 0,
'id': 9021906, 'eyes': 0},
'node_id': 'MI_kwDOAA0YD84AianS', 'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5800
'number': 102, 1/timeline',
'title': '3.0', 'performed_via_github_app': None,
'description': '', 'state_reason': None},
'creator': {'login': 'jbrockmendel', {'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57999',
'id': 8078968, 'repository_url': 'https://api.github.com/repos/pandas-dev/pandas',
'node_id': 'MDQ6VXNlcjgwNzg5Njg=', 'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57999/
'avatar_url': 'https://avatars.githubusercontent.com/u/8078968?v=4', labels{/name}',
'gravatar_id': '', 'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5799
'url': 'https://api.github.com/users/jbrockmendel', 9/comments',
'html_url': 'https://github.com/jbrockmendel', 'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57999/
'followers_url': 'https://api.github.com/users/jbrockmendel/followers', events',
'following_url': 'https://api.github.com/users/jbrockmendel/following{/ot 'html_url': 'https://github.com/pandas-dev/pandas/pull/57999',
her_user}', 'id': 2206649509,
'gists_url': 'https://api.github.com/users/jbrockmendel/gists{/gist_id}', 'node_id': 'PR_kwDOAA0YD85qtMxt',
'starred_url': 'https://api.github.com/users/jbrockmendel/starred{/owne 'number': 57999,
r}{/repo}', 'title': 'DEPR: Enforce datetimelike deprecations',
'subscriptions_url': 'https://api.github.com/users/jbrockmendel/subscript 'user': {'login': 'jbrockmendel',
ions', 'id': 8078968,
'organizations_url': 'https://api.github.com/users/jbrockmendel/orgs', 'node_id': 'MDQ6VXNlcjgwNzg5Njg=',
'repos_url': 'https://api.github.com/users/jbrockmendel/repos', 'avatar_url': 'https://avatars.githubusercontent.com/u/8078968?v=4',
'events_url': 'https://api.github.com/users/jbrockmendel/events{/privac 'gravatar_id': '',
y}', 'url': 'https://api.github.com/users/jbrockmendel',
'received_events_url': 'https://api.github.com/users/jbrockmendel/receive 'html_url': 'https://github.com/jbrockmendel',
d_events', 'followers_url': 'https://api.github.com/users/jbrockmendel/followers',
'type': 'User', 'following_url': 'https://api.github.com/users/jbrockmendel/following{/oth
'site_admin': False}, er_user}',
'open_issues': 51, 'gists_url': 'https://api.github.com/users/jbrockmendel/gists{/gist_id}',
'closed_issues': 481, 'starred_url': 'https://api.github.com/users/jbrockmendel/starred{/owne
'state': 'open', r}{/repo}',
'created_at': '2023-02-08T18:16:49Z', 'subscriptions_url': 'https://api.github.com/users/jbrockmendel/subscripti
'updated_at': '2024-03-27T03:43:05Z', ons',
'due_on': '2024-04-01T07:00:00Z', 'organizations_url': 'https://api.github.com/users/jbrockmendel/orgs',
'closed_at': None}, 'repos_url': 'https://api.github.com/users/jbrockmendel/repos',
'comments': 0, 'events_url': 'https://api.github.com/users/jbrockmendel/events{/privac
'created_at': '2024-03-25T20:38:09Z', y}',
'updated_at': '2024-03-25T20:38:10Z', 'received_events_url': 'https://api.github.com/users/jbrockmendel/receive
'closed_at': None, d_events',
'type': 'User', labels{/name}',
'site_admin': False}, 'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5799
'labels': [{'id': 211029535, 5/comments',
'node_id': 'MDU6TGFiZWwyMTEwMjk1MzU=', 'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57995/
'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Clean', events',
'name': 'Clean', 'html_url': 'https://github.com/pandas-dev/pandas/pull/57995',
'color': '207de5', 'id': 2206376352,
'default': False, 'node_id': 'PR_kwDOAA0YD85qsQIt',
'description': None}], 'number': 57995,
'state': 'open', 'title': 'FIX #57645: Cannot use numpy FLS as indicies since pandas 2.2.1',
'locked': False, 'user': {'login': 'PF2100',
'assignee': None, 'id': 102478434,
'assignees': [], 'node_id': 'U_kgDOBhuyYg',
'milestone': None, 'avatar_url': 'https://avatars.githubusercontent.com/u/102478434?v=4',
'comments': 0, 'gravatar_id': '',
'created_at': '2024-03-25T20:30:17Z', 'url': 'https://api.github.com/users/PF2100',
'updated_at': '2024-03-26T17:52:31Z', 'html_url': 'https://github.com/PF2100',
'closed_at': None, 'followers_url': 'https://api.github.com/users/PF2100/followers',
'author_association': 'MEMBER', 'following_url': 'https://api.github.com/users/PF2100/following{/other_use
'active_lock_reason': None, r}',
'draft': False, 'gists_url': 'https://api.github.com/users/PF2100/gists{/gist_id}',
'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul 'starred_url': 'https://api.github.com/users/PF2100/starred{/owner}{/rep
ls/57999', o}',
'html_url': 'https://github.com/pandas-dev/pandas/pull/57999', 'subscriptions_url': 'https://api.github.com/users/PF2100/subscriptions',
'diff_url': 'https://github.com/pandas-dev/pandas/pull/57999.diff', 'organizations_url': 'https://api.github.com/users/PF2100/orgs',
'patch_url': 'https://github.com/pandas-dev/pandas/pull/57999.patch', 'repos_url': 'https://api.github.com/users/PF2100/repos',
'merged_at': None}, 'events_url': 'https://api.github.com/users/PF2100/events{/privacy}',
'body': '- [ ] closes #xxxx (Replace xxxx with the GitHub issue number)\r\ 'received_events_url': 'https://api.github.com/users/PF2100/received_event
n- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/dev s',
elopment/contributing_codebase.html#writing-tests) if fixing a bug or adding 'type': 'User',
a new feature\r\n- [ ] All [code checks passed](https://pandas.pydata.org/pan 'site_admin': False},
das-docs/dev/development/contributing_codebase.html#pre-commit).\r\n- [ ] Add 'labels': [],
ed [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/c 'state': 'open',
ontributing_codebase.html#type-hints) to new arguments/methods/functions.\r\ 'locked': False,
n- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if 'assignee': None,
fixing a bug or adding a new feature.\r\n', 'assignees': [],
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'milestone': None,
s/57999/reactions', 'comments': 0,
'total_count': 0, 'created_at': '2024-03-25T18:07:42Z',
'+1': 0, 'updated_at': '2024-03-26T00:17:13Z',
'-1': 0, 'closed_at': None,
'laugh': 0, 'author_association': 'NONE',
'hooray': 0, 'active_lock_reason': None,
'confused': 0, 'draft': False,
'heart': 0, 'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul
'rocket': 0, ls/57995',
'eyes': 0}, 'html_url': 'https://github.com/pandas-dev/pandas/pull/57995',
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5799 'diff_url': 'https://github.com/pandas-dev/pandas/pull/57995.diff',
9/timeline', 'patch_url': 'https://github.com/pandas-dev/pandas/pull/57995.patch',
'performed_via_github_app': None, 'merged_at': None},
'state_reason': None}, 'body': '- [X] closes #57645 \r\n- [X] [Tests added and passed] if fixing a
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57995', bug or adding a new feature\r\n- [X] All [code checks passed].\r\n- [ ] Added
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', [type annotations] to new arguments/methods/functions.\r\n- [X] Added an entr
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57995/ y in the latest `doc/source/whatsnew/v3.0.0.rst` file if fixing a bug or addi
ng a new feature.\r\n\r\nWhile using the function set_index with parameter in y}',
place=True, the function would try and create a new index where its dtype wou 'received_events_url': 'https://api.github.com/users/alexandermorgan/recei
ld be a FLS `S{value}` dtype, which was not recognized by the function `_dtyp ved_events',
e_to_subclass` and raised a NotImplementedError. That said , by adding a veri 'type': 'User',
fication that recognizes FLS dtype , the index is created successfully and th 'site_admin': False},
e function executes properly.\r\n', 'labels': [{'id': 134699,
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'node_id': 'MDU6TGFiZWwxMzQ2OTk=',
s/57995/reactions', 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Docs',
'total_count': 0, 'name': 'Docs',
'+1': 0, 'color': '3465A4',
'-1': 0, 'default': False,
'laugh': 0, 'description': None},
'hooray': 0, {'id': 2822098,
'confused': 0, 'node_id': 'MDU6TGFiZWwyODIyMDk4',
'heart': 0, 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Indexing',
'rocket': 0, 'name': 'Indexing',
'eyes': 0}, 'color': '0b02e1',
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5799 'default': False,
5/timeline', 'description': 'Related to indexing on series/frames, not to indexes them
'performed_via_github_app': None, selves'}],
'state_reason': None}, 'state': 'open',
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57994', 'locked': False,
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'assignee': None,
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57994/ 'assignees': [],
labels{/name}', 'milestone': None,
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5799 'comments': 5,
4/comments', 'created_at': '2024-03-25T15:23:05Z',
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57994/ 'updated_at': '2024-03-26T20:43:22Z',
events', 'closed_at': None,
'html_url': 'https://github.com/pandas-dev/pandas/issues/57994', 'author_association': 'NONE',
'id': 2206025644, 'active_lock_reason': None,
'node_id': 'I_kwDOAA0YD86DfUes', 'body': '### Pandas version checks\r\n\r\n- [X] I have checked that the iss
'number': 57994, ue still exists on the latest versions of the docs on `main` [here](https://p
'title': "DOC: DataFrame.reset_index names param can't be a tuple as docs s andas.pydata.org/docs/dev/)\r\n\r\n\r\n### Location of the documentation\r\n\
tate", r\n[https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.reset_inde
'user': {'login': 'alexandermorgan', x.html](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.reset_i
'id': 2601689, ndex.html)\r\n\r\n### Documentation problem\r\n\r\nIn the description of the
'node_id': 'MDQ6VXNlcjI2MDE2ODk=', `names` parameter, the declared type in bold is correct: "int, str or 1-dimen
'avatar_url': 'https://avatars.githubusercontent.com/u/2601689?v=4', sional list, default None"\r\n\r\nBut the expanded description that immediate
'gravatar_id': '', ly follows incorrectly states that `names` can be a tuple: "If the DataFrame
'url': 'https://api.github.com/users/alexandermorgan', has a MultiIndex, this has to be a list or tuple with length equal to the num
'html_url': 'https://github.com/alexandermorgan', ber of levels."\r\n\r\nThis is incorrect because passing a tuple as the `name
'followers_url': 'https://api.github.com/users/alexandermorgan/followers', s` parameter raises this error: \'raise ValueError("Index names must be str o
'following_url': 'https://api.github.com/users/alexandermorgan/followin r 1-dimensional list")\'\r\n\r\n### Suggested fix for documentation\r\n\r\nRe
g{/other_user}', move " or tuple" from the expanded documentation description. This will cause
'gists_url': 'https://api.github.com/users/alexandermorgan/gists{/gist_i it to match the bold-face type description, and more importantly accurately r
d}', eflect the behavior. I can submit a PR for this if that\'s preferred.',
'starred_url': 'https://api.github.com/users/alexandermorgan/starred{/owne 'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue
r}{/repo}', s/57994/reactions',
'subscriptions_url': 'https://api.github.com/users/alexandermorgan/subscri 'total_count': 0,
ptions', '+1': 0,
'organizations_url': 'https://api.github.com/users/alexandermorgan/orgs', '-1': 0,
'repos_url': 'https://api.github.com/users/alexandermorgan/repos', 'laugh': 0,
'events_url': 'https://api.github.com/users/alexandermorgan/events{/privac 'hooray': 0,
'confused': 0, 'node_id': 'MDU6TGFiZWwxOTU0NzIwMjkw',
'heart': 0, 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Needs%20Tri
'rocket': 0, age',
'eyes': 0}, 'name': 'Needs Triage',
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5799 'color': '0052cc',
4/timeline', 'default': False,
'performed_via_github_app': None, 'description': 'Issue that has not been reviewed by a pandas team membe
'state_reason': None}, r'}],
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57993', 'state': 'open',
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'locked': False,
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57993/ 'assignee': None,
labels{/name}', 'assignees': [],
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5799 'milestone': None,
3/comments', 'comments': 0,
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57993/ 'created_at': '2024-03-25T08:20:37Z',
events', 'updated_at': '2024-03-25T08:20:37Z',
'html_url': 'https://github.com/pandas-dev/pandas/issues/57993', 'closed_at': None,
'id': 2205160785, 'author_association': 'CONTRIBUTOR',
'node_id': 'I_kwDOAA0YD86DcBVR', 'active_lock_reason': None,
'number': 57993, 'body': '### Pandas version checks\n\n- [X] I have checked that this issue
'title': 'BUG: Nones in pd.concat MultiIndex keys are not accepted in some has not already been reported.\n\n- [X] I have confirmed this bug exists on t
cases', he [latest version](https://pandas.pydata.org/docs/whatsnew/index.html) of pa
'user': {'login': 'batterseapower', ndas.\n\n- [ ] I have confirmed this bug exists on the [main branch](http
'id': 18488, s://pandas.pydata.org/docs/dev/getting_started/install.html#installing-the-de
'node_id': 'MDQ6VXNlcjE4NDg4', velopment-version-of-pandas) of pandas.\n\n\n### Reproducible Example\n\n```p
'avatar_url': 'https://avatars.githubusercontent.com/u/18488?v=4', ython\nimport pandas as pd\r\npd.concat({\r\n (\'a\', None): pd.DataFram
'gravatar_id': '', e(columns=[0], index=[\'a\'])\r\n}, axis=1, names=[\'a\', \'b\'])\n```\n\n\
'url': 'https://api.github.com/users/batterseapower', n### Issue Description\n\nThe program above fails with a "Values not found in
'html_url': 'https://github.com/batterseapower', passed level" error:\r\n\r\n```\r\n File "C:\\Users\\mboling\\Anaconda3\\env
'followers_url': 'https://api.github.com/users/batterseapower/followers', s\\py3\\lib\\site-packages\\pandas\\core\\reshape\\concat.py", line 393, in c
'following_url': 'https://api.github.com/users/batterseapower/following{/o oncat\r\n return op.get_result()\r\n File "C:\\Users\\mboling\\Anaconda
ther_user}', 3\\envs\\py3\\lib\\site-packages\\pandas\\core\\reshape\\concat.py", line 66
'gists_url': 'https://api.github.com/users/batterseapower/gists{/gist_i 7, in get_result\r\n for ax, new_labels in enumerate(self.new_axes):\r\n
d}', File "properties.pyx", line 36, in pandas._libs.properties.CachedProperty.__g
'starred_url': 'https://api.github.com/users/batterseapower/starred{/owne et__\r\n File "C:\\Users\\mboling\\Anaconda3\\envs\\py3\\lib\\site-package
r}{/repo}', s\\pandas\\core\\reshape\\concat.py", line 698, in new_axes\r\n return
'subscriptions_url': 'https://api.github.com/users/batterseapower/subscrip [\r\n File "C:\\Users\\mboling\\Anaconda3\\envs\\py3\\lib\\site-packages\\pa
tions', ndas\\core\\reshape\\concat.py", line 699, in <listcomp>\r\n self._get_con
'organizations_url': 'https://api.github.com/users/batterseapower/orgs', cat_axis if i == self.bm_axis else self._get_comb_axis(i)\r\n File "properti
'repos_url': 'https://api.github.com/users/batterseapower/repos', es.pyx", line 36, in pandas._libs.properties.CachedProperty.__get__\r\n File
'events_url': 'https://api.github.com/users/batterseapower/events{/privac "C:\\Users\\mboling\\Anaconda3\\envs\\py3\\lib\\site-packages\\pandas\\cor
y}', e\\reshape\\concat.py", line 758, in _get_concat_axis\r\n concat_axis = _m
'received_events_url': 'https://api.github.com/users/batterseapower/receiv ake_concat_multiindex(\r\n File "C:\\Users\\mboling\\Anaconda3\\envs\\py3\\l
ed_events', ib\\site-packages\\pandas\\core\\reshape\\concat.py", line 871, in _make_conc
'type': 'User', at_multiindex\r\n raise ValueError(f"Values not found in passed level: {hl
'site_admin': False}, evel[mask]!s}")\r\nValueError: Values not found in passed level: Index([nan],
'labels': [{'id': 76811, dtype=\'float64\')\r\n```\n\n### Expected Behavior\n\nIf you use keys which c
'node_id': 'MDU6TGFiZWw3NjgxMQ==', ontain a None/np.nan, `pd.concat` should return a new frame with the appropri
'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Bug', ate index level containing either None or np.nan.\r\n\r\nThis already works i
'name': 'Bug', f you use `pd.concat` to concat a series instead:\r\n\r\n```\r\n>>> pd.conca
'color': 'e10c02', t({\r\n (\'a\', None): pd.Series(index=[0])\r\n... }, axis=1, name
'default': False, s=[\'a\', \'b\'])...\r\na a\r\nb NaN\r\n0 NaN\r\n```\r\n\r\nOr if you conca
'description': None}, t DataFrames, but just have a *single* level that contains None:\r\n\r\
{'id': 1954720290, n```\r\n>>> pd.concat({\r\n None: pd.DataFrame(columns=[0], inde
x=[\'a\'])\r\n... }, axis=1, names=[\'a\'])...\r\na None\r\n 0\r\na NaN\ 'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57990/
r\n```\r\n\r\nThere is obviously some existing inconsistency here about wheth events',
er None or np.nan is used. I think it would make sense to avoid introducing n 'html_url': 'https://github.com/pandas-dev/pandas/pull/57990',
p.nan, but opinions might differ on this. The important thing is that Pandas 'id': 2204739364,
shouldn\'t fail in this case.\n\n### Installed Versions\n\n<details>\r\n\r\nI 'node_id': 'PR_kwDOAA0YD85qmpFT',
NSTALLED VERSIONS\r\n------------------\r\ncommit : fd3f57170a 'number': 57990,
a1af588ba877e8e28c158a20a4886d\r\npython : 3.11.6.final.0\r\np 'title': 'DOC: ecosystem.md: add pygwalker, add seaborn code example',
ython-bits : 64\r\nOS : Linux\r\nOS-release 'user': {'login': 'westurner',
: 4.18.0-348.20.1.el8_5.x86_64\r\nVersion : #1 SMP Thu Mar 10 2 'id': 50891,
0:59:28 UTC 2022\r\nmachine : x86_64\r\nprocessor : 'node_id': 'MDQ6VXNlcjUwODkx',
x86_64\r\nbyteorder : little\r\nLC_ALL : None\r\nL 'avatar_url': 'https://avatars.githubusercontent.com/u/50891?v=4',
ANG : en_GB.UTF-8\r\nLOCALE : en_GB.UTF-8\r\ 'gravatar_id': '',
n\r\npandas : 2.2.0\r\nnumpy : 1.26.3\r\npytz 'url': 'https://api.github.com/users/westurner',
: 2023.3.post1\r\ndateutil : 2.8.2\r\nsetuptools : 6 'html_url': 'https://github.com/westurner',
9.0.3\r\npip : 23.3.2\r\nCython : None\r\npy 'followers_url': 'https://api.github.com/users/westurner/followers',
test : 7.4.4\r\nhypothesis : None\r\nsphinx 'following_url': 'https://api.github.com/users/westurner/following{/othe
: None\r\nblosc : None\r\nfeather : None\r\nxls r_user}',
xwriter : 3.1.9\r\nlxml.etree : 5.1.0\r\nhtml5lib 'gists_url': 'https://api.github.com/users/westurner/gists{/gist_id}',
: 1.1\r\npymysql : None\r\npsycopg2 : None\r\njinj 'starred_url': 'https://api.github.com/users/westurner/starred{/owner}{/re
a2 : 3.1.3\r\nIPython : 8.20.0\r\npandas_datarea po}',
der : None\r\nadbc-driver-postgresql: None\r\nadbc-driver-sqlite : Non 'subscriptions_url': 'https://api.github.com/users/westurner/subscription
e\r\nbs4 : 4.12.3\r\nbottleneck : 1.3.7\r\ndataf s',
rame-api-compat : None\r\nfastparquet : None\r\nfsspec 'organizations_url': 'https://api.github.com/users/westurner/orgs',
: 2023.12.2\r\ngcsfs : None\r\nmatplotlib : 3.8.2\ 'repos_url': 'https://api.github.com/users/westurner/repos',
r\nnumba : 0.58.1\r\nnumexpr : None\r\nodfpy 'events_url': 'https://api.github.com/users/westurner/events{/privacy}',
: None\r\nopenpyxl : 3.1.2\r\npandas_gbq : None\r\npy 'received_events_url': 'https://api.github.com/users/westurner/received_ev
arrow : 14.0.2\r\npyreadstat : None\r\npython-calami ents',
ne : None\r\npyxlsb : None\r\ns3fs : No 'type': 'User',
ne\r\nscipy : 1.12.0\r\nsqlalchemy : None\r\ntable 'site_admin': False},
s : None\r\ntabulate : None\r\nxarray 'labels': [{'id': 134699,
: 2024.1.0\r\nxlrd : 2.0.1\r\nzstandard : None\ 'node_id': 'MDU6TGFiZWwxMzQ2OTk=',
r\ntzdata : 2023.4\r\nqtpy : 2.4.1\r\npyqt5 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Docs',
: None\r\n\r\n</details>\r\n', 'name': 'Docs',
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'color': '3465A4',
s/57993/reactions', 'default': False,
'total_count': 0, 'description': None}],
'+1': 0, 'state': 'open',
'-1': 0, 'locked': False,
'laugh': 0, 'assignee': None,
'hooray': 0, 'assignees': [],
'confused': 0, 'milestone': None,
'heart': 0, 'comments': 1,
'rocket': 0, 'created_at': '2024-03-25T02:12:12Z',
'eyes': 0}, 'updated_at': '2024-03-25T17:34:15Z',
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5799 'closed_at': None,
3/timeline', 'author_association': 'CONTRIBUTOR',
'performed_via_github_app': None, 'active_lock_reason': None,
'state_reason': None}, 'draft': False,
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57990', 'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', ls/57990',
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57990/ 'html_url': 'https://github.com/pandas-dev/pandas/pull/57990',
labels{/name}', 'diff_url': 'https://github.com/pandas-dev/pandas/pull/57990.diff',
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5799 'patch_url': 'https://github.com/pandas-dev/pandas/pull/57990.patch',
0/comments', 'merged_at': None},
'body': '- [ ] closes #xxxx (Replace xxxx with the GitHub issue number)\r\ riptions',
n- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/dev 'organizations_url': 'https://api.github.com/users/filip-komarzyniec/org
elopment/contributing_codebase.html#writing-tests) if fixing a bug or adding s',
a new feature\r\n- [ ] All [code checks passed](https://pandas.pydata.org/pan 'repos_url': 'https://api.github.com/users/filip-komarzyniec/repos',
das-docs/dev/development/contributing_codebase.html#pre-commit).\r\n- [ ] Add 'events_url': 'https://api.github.com/users/filip-komarzyniec/events{/priv
ed [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/c acy}',
ontributing_codebase.html#type-hints) to new arguments/methods/functions.\r\ 'received_events_url': 'https://api.github.com/users/filip-komarzyniec/rec
n- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if eived_events',
fixing a bug or adding a new feature.\r\n', 'type': 'User',
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'site_admin': False},
s/57990/reactions', 'labels': [{'id': 76811,
'total_count': 0, 'node_id': 'MDU6TGFiZWw3NjgxMQ==',
'+1': 0, 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Bug',
'-1': 0, 'name': 'Bug',
'laugh': 0, 'color': 'e10c02',
'hooray': 0, 'default': False,
'confused': 0, 'description': None},
'heart': 0, {'id': 2822342,
'rocket': 0, 'node_id': 'MDU6TGFiZWwyODIyMzQy',
'eyes': 0}, 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Missing-dat
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5799 a',
0/timeline', 'name': 'Missing-data',
'performed_via_github_app': None, 'color': 'd7e102',
'state_reason': None}, 'default': False,
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57989', 'description': 'np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate'}],
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'state': 'open',
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57989/ 'locked': False,
labels{/name}', 'assignee': None,
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5798 'assignees': [],
9/comments', 'milestone': None,
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57989/ 'comments': 2,
events', 'created_at': '2024-03-25T00:52:11Z',
'html_url': 'https://github.com/pandas-dev/pandas/issues/57989', 'updated_at': '2024-03-25T01:28:58Z',
'id': 2204659919, 'closed_at': None,
'node_id': 'I_kwDOAA0YD86DaHDP', 'author_association': 'NONE',
'number': 57989, 'active_lock_reason': None,
'title': 'BUG: CONTAINS_OP run on pd.NA results in pd.NAType.__bool__ cal 'body': '### Pandas version checks\r\n\r\n- [X] I have checked that this is
l', sue has not already been reported.\r\n\r\n- [X] I have confirmed this bug exi
'user': {'login': 'filip-komarzyniec', sts on the [latest version](https://pandas.pydata.org/docs/whatsnew/index.htm
'id': 39336739, l) of pandas.\r\n\r\n- [X] I have confirmed this bug exists on the [main bran
'node_id': 'MDQ6VXNlcjM5MzM2NzM5', ch](https://pandas.pydata.org/docs/dev/getting_started/install.html#installin
'avatar_url': 'https://avatars.githubusercontent.com/u/39336739?v=4', g-the-development-version-of-pandas) of pandas.\r\n\r\n\r\n### Reproducible E
'gravatar_id': '', xample\r\n\r\n```python\r\nimport pandas as pd\r\n\r\npd.NA in [1,2,3]\r\
'url': 'https://api.github.com/users/filip-komarzyniec', n```\r\n\r\n```python-traceback\r\nTraceback (most recent call last):\r\n Fi
'html_url': 'https://github.com/filip-komarzyniec', le "<stdin>", line 1, in <module>\r\n File "missing.pyx", line 392, in panda
'followers_url': 'https://api.github.com/users/filip-komarzyniec/follower s._libs.missing.NAType.__bool__\r\nTypeError: boolean value of NA is ambiguou
s', s\r\n```\r\n\r\n### Issue Description\r\n\r\nchecking for `pd.NA` existence i
'following_url': 'https://api.github.com/users/filip-komarzyniec/followin n a list results in `TypeError: boolean value of NA is ambiguous`. \r\nWhy i
g{/other_user}', s performing `in` operation calls `__bool__` method of the `pd.NAType` class?
'gists_url': 'https://api.github.com/users/filip-komarzyniec/gists{/gist_i \r\n\r\nSeems a bit similar to the issue regarding incorrect implementation o
d}', f some operators: https://github.com/pandas-dev/pandas/issues/49828\r\n\r\n\
'starred_url': 'https://api.github.com/users/filip-komarzyniec/starred{/ow r\n### Expected Behavior\r\n\r\nChecking for existence of `pd.NA` type in any
ner}{/repo}', container should correctly return either `True` or `False`\r\n\r\n### Install
'subscriptions_url': 'https://api.github.com/users/filip-komarzyniec/subsc ed Versions\r\n\r\n<details>\r\n\r\nINSTALLED VERSIONS\r\n------------------
\r\ncommit : bdc79c146c2e32f2cab629be240f01658cfb6cc2\r\npytho 'title': 'PERF: (partial) fix for np_datetime.c performance regression',
n : 3.10.13.final.0\r\npython-bits : 64\r\nOS 'user': {'login': 'dontgoto',
: Darwin\r\nOS-release : 23.2.0\r\nVersion : Darwin 'id': 6079615,
Kernel Version 23.2.0: Wed Nov 15 21:55:06 PST 2023; root:xnu-10002.61.3~2/RE 'node_id': 'MDQ6VXNlcjYwNzk2MTU=',
LEASE_ARM64_T6020\r\nmachine : x86_64\r\nprocessor 'avatar_url': 'https://avatars.githubusercontent.com/u/6079615?v=4',
: i386\r\nbyteorder : little\r\nLC_ALL : None\r\nL 'gravatar_id': '',
ANG : None\r\nLOCALE : None.UTF-8\r\n\r\npand 'url': 'https://api.github.com/users/dontgoto',
as : 2.2.1\r\nnumpy : 1.26.3\r\npytz 'html_url': 'https://github.com/dontgoto',
: 2024.1\r\ndateutil : 2.8.2\r\nsetuptools : 68.2.2\ 'followers_url': 'https://api.github.com/users/dontgoto/followers',
r\npip : 23.3.1\r\nCython : None\r\npytest 'following_url': 'https://api.github.com/users/dontgoto/following{/other_u
: 8.0.0\r\nhypothesis : None\r\nsphinx : None\r\nbl ser}',
osc : None\r\nfeather : None\r\nxlsxwriter 'gists_url': 'https://api.github.com/users/dontgoto/gists{/gist_id}',
: None\r\nlxml.etree : None\r\nhtml5lib : None\r\npym 'starred_url': 'https://api.github.com/users/dontgoto/starred{/owner}{/rep
ysql : None\r\npsycopg2 : None\r\njinja2 o}',
: None\r\nIPython : None\r\npandas_datareader : None\r\nadb 'subscriptions_url': 'https://api.github.com/users/dontgoto/subscription
c-driver-postgresql: None\r\nadbc-driver-sqlite : None\r\nbs4 s',
: None\r\nbottleneck : None\r\ndataframe-api-compat : None\r\nfas 'organizations_url': 'https://api.github.com/users/dontgoto/orgs',
tparquet : None\r\nfsspec : None\r\ngcsfs 'repos_url': 'https://api.github.com/users/dontgoto/repos',
: None\r\nmatplotlib : None\r\nnumba : None\r\nnum 'events_url': 'https://api.github.com/users/dontgoto/events{/privacy}',
expr : None\r\nodfpy : None\r\nopenpyxl 'received_events_url': 'https://api.github.com/users/dontgoto/received_eve
: None\r\npandas_gbq : None\r\npyarrow : None\r\npyr nts',
eadstat : None\r\npython-calamine : None\r\npyxlsb 'type': 'User',
: None\r\ns3fs : None\r\nscipy : 1.12.0\r\ns 'site_admin': False},
qlalchemy : None\r\ntables : None\r\ntabulate 'labels': [{'id': 8935311,
: 0.9.0\r\nxarray : None\r\nxlrd : None\r\nzs 'node_id': 'MDU6TGFiZWw4OTM1MzEx',
tandard : None\r\ntzdata : 2024.1\r\nqtpy 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Performanc
: None\r\npyqt5 : None\r\n\r\n</details>\r\n', e',
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'name': 'Performance',
s/57989/reactions', 'color': 'a10c02',
'total_count': 0, 'default': False,
'+1': 0, 'description': 'Memory or execution speed performance'}],
'-1': 0, 'state': 'open',
'laugh': 0, 'locked': False,
'hooray': 0, 'assignee': None,
'confused': 0, 'assignees': [],
'heart': 0, 'milestone': None,
'rocket': 0, 'comments': 1,
'eyes': 0}, 'created_at': '2024-03-25T00:01:30Z',
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5798 'updated_at': '2024-03-26T22:53:04Z',
9/timeline', 'closed_at': None,
'performed_via_github_app': None, 'author_association': 'CONTRIBUTOR',
'state_reason': None}, 'active_lock_reason': None,
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57988', 'draft': False,
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57988/ ls/57988',
labels{/name}', 'html_url': 'https://github.com/pandas-dev/pandas/pull/57988',
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5798 'diff_url': 'https://github.com/pandas-dev/pandas/pull/57988.diff',
8/comments', 'patch_url': 'https://github.com/pandas-dev/pandas/pull/57988.patch',
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57988/ 'merged_at': None},
events', 'body': '- [x] All [code checks passed](https://pandas.pydata.org/pandas-do
'html_url': 'https://github.com/pandas-dev/pandas/pull/57988', cs/dev/development/contributing_codebase.html#pre-commit).\r\n\r\nFixes (par
'id': 2204629428, t) of the performance regression seen mentioned in #57951. The main performan
'node_id': 'PR_kwDOAA0YD85qmRIF', ce improvements are the ~~ ~~refactoring of the "days" parsing logic~~ and th
'number': 57988, e simpler calculation of ifrac.\r\n\r\nThe days parsing refactoring needed to
be reverted. I overlooked an issue that happens for td close to int64 bounds 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/IO%20JSON',
there.', 'name': 'IO JSON',
'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue 'color': '207de5',
s/57988/reactions', 'default': False,
'total_count': 0, 'description': 'read_json, to_json, json_normalize'},
'+1': 0, {'id': 87485152,
'-1': 0, 'node_id': 'MDU6TGFiZWw4NzQ4NTE1Mg==',
'laugh': 0, 'url': 'https://api.github.com/repos/pandas-dev/pandas/labels/Deprecate',
'hooray': 0, 'name': 'Deprecate',
'confused': 0, 'color': '5319e7',
'heart': 0, 'default': False,
'rocket': 0, 'description': 'Functionality to remove in pandas'}],
'eyes': 0}, 'state': 'open',
'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5798 'locked': False,
8/timeline', 'assignee': None,
'performed_via_github_app': None, 'assignees': [],
'state_reason': None}, 'milestone': None,
{'url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57987', 'comments': 1,
'repository_url': 'https://api.github.com/repos/pandas-dev/pandas', 'created_at': '2024-03-24T23:11:37Z',
'labels_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57987/ 'updated_at': '2024-03-25T19:00:44Z',
labels{/name}', 'closed_at': None,
'comments_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5798 'author_association': 'CONTRIBUTOR',
7/comments', 'active_lock_reason': None,
'events_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/57987/ 'draft': False,
events', 'pull_request': {'url': 'https://api.github.com/repos/pandas-dev/pandas/pul
'html_url': 'https://github.com/pandas-dev/pandas/pull/57987', ls/57987',
'id': 2204607994, 'html_url': 'https://github.com/pandas-dev/pandas/pull/57987',
'node_id': 'PR_kwDOAA0YD85qmMuv', 'diff_url': 'https://github.com/pandas-dev/pandas/pull/57987.diff',
'number': 57987, 'patch_url': 'https://github.com/pandas-dev/pandas/pull/57987.patch',
'title': "DEPR: 'epoch' date format in to_json", 'merged_at': None},
'user': {'login': 'Aloqeely', 'body': '- [x] closes #57063 \r\n- [x] [Tests added and passed](https://pan
'id': 52792999, das.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writin
'node_id': 'MDQ6VXNlcjUyNzkyOTk5', g-tests) if fixing a bug or adding a new feature\r\n- [ ] All [code checks pa
'avatar_url': 'https://avatars.githubusercontent.com/u/52792999?v=4', ssed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_code
'gravatar_id': '', base.html#pre-commit).\r\n- [ ] Added [type annotations](https://pandas.pydat
'url': 'https://api.github.com/users/Aloqeely', a.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to n
'html_url': 'https://github.com/Aloqeely', ew arguments/methods/functions.\r\n- [x] Added an entry in the latest `doc/so
'followers_url': 'https://api.github.com/users/Aloqeely/followers', urce/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.\r\n',
'following_url': 'https://api.github.com/users/Aloqeely/following{/other_u 'reactions': {'url': 'https://api.github.com/repos/pandas-dev/pandas/issue
ser}', s/57987/reactions',
'gists_url': 'https://api.github.com/users/Aloqeely/gists{/gist_id}', 'total_count': 0,
'starred_url': 'https://api.github.com/users/Aloqeely/starred{/owner}{/rep '+1': 0,
o}', '-1': 0,
'subscriptions_url': 'https://api.github.com/users/Aloqeely/subscription 'laugh': 0,
s', 'hooray': 0,
'organizations_url': 'https://api.github.com/users/Aloqeely/orgs', 'confused': 0,
'repos_url': 'https://api.github.com/users/Aloqeely/repos', 'heart': 0,
'events_url': 'https://api.github.com/users/Aloqeely/events{/privacy}', 'rocket': 0,
'received_events_url': 'https://api.github.com/users/Aloqeely/received_eve 'eyes': 0},
nts', 'timeline_url': 'https://api.github.com/repos/pandas-dev/pandas/issues/5798
'type': 'User', 7/timeline',
'site_admin': False}, 'performed_via_github_app': None,
'labels': [{'id': 49379259, 'state_reason': None}]
'node_id': 'MDU6TGFiZWw0OTM3OTI1OQ==',
In [ ]: In [1]: #Solving the dataset
import pandas as pd

df = pd.read_csv("https://raw.githubusercontent.com/datasciencedojo/datasets/master/ti

In [2]: df
Out[2]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket In [4]: df.head()

Braund, Out[4]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket
A/5
0 1 0 3 Mr. Owen male 22.0 1 0
21171 Braund,
Harris A/5
0 1 0 3 Mr. Owen male 22.0 1 0
21171
Cumings, Harris
Mrs. John
Bradley PC Cumings,
1 2 1 1 female 38.0 1 0 Mrs. John
(Florence 17599
Briggs Bradley PC
1 2 1 1 female 38.0 1 0
Th... (Florence 17599
Briggs
Heikkinen, STON/ Th...
2 3 1 3 Miss. female 26.0 0 0 O2.
Laina 3101282 Heikkinen, STON/
2 3 1 3 Miss. female 26.0 0 0 O2.
Futrelle, Laina 3101282
Mrs.
Jacques Futrelle,
3 4 1 1 female 35.0 1 0 113803 Mrs.
Heath
(Lily May Jacques
3 4 1 1 female 35.0 1 0 113803
Peel) Heath
(Lily May
Allen, Mr. Peel)
4 5 0 3 William male 35.0 0 0 373450
Henry Allen, Mr.
4 5 0 3 William male 35.0 0 0 373450
... ... ... ... ... ... ... ... ... ... Henry

Montvila,
886 887 0 2 Rev. male 27.0 0 0 211536
Juozas In [5]: df.tail()

Graham, Out[5]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket
Miss.
887 888 1 1 female 19.0 0 0 112053 Montvila,
Margaret
Edith 886 887 0 2 Rev. male 27.0 0 0 211536
Juozas
Johnston,
Miss. Graham,
W./C. Miss.
888 889 0 3 Catherine female NaN 1 2 887 888 1 1 female 19.0 0 0 112053
6607 Margaret
Helen
"Carrie" Edith

Behr, Mr. Johnston,


889 890 1 1 Karl male 26.0 0 0 111369 Miss.
W./C.
Howell 888 889 0 3 Catherine female NaN 1 2
6607
Helen
Dooley, "Carrie"
890 891 0 3 male 32.0 0 0 370376
Mr. Patrick
Behr, Mr.
889 890 1 1 Karl male 26.0 0 0 111369
891 rows × 12 columns Howell

Dooley,
In [3]: df.columns 890 891 0 3 Mr. male 32.0 0 0 370376
Patrick
Out[3]: Index(['PassengerId', 'Survived', 'Pclass', 'Name', 'Sex', 'Age', 'SibSp',
'Parch', 'Ticket', 'Fare', 'Cabin', 'Embarked'],
dtype='object') In [6]: df.dtypes
Out[6]: PassengerId int64 In [10]: df[['PassengerId', 'Survived', 'Pclass']]
Survived int64
Pclass int64 Out[10]: PassengerId Survived Pclass
Name object
0 1 0 3
Sex object
Age float64 1 2 1 1
SibSp int64
Parch int64 2 3 1 3
Ticket object 3 4 1 1
Fare float64
Cabin object 4 5 0 3
Embarked object
dtype: object ... ... ... ...

886 887 0 2
In [7]: df.info()
887 888 1 1
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 891 entries, 0 to 890 888 889 0 3
Data columns (total 12 columns):
# Column Non-Null Count Dtype 889 890 1 1
--- ------ -------------- ----- 890 891 0 3
0 PassengerId 891 non-null int64
1 Survived 891 non-null int64
2 Pclass 891 non-null int64 891 rows × 3 columns
3 Name 891 non-null object
4 Sex 891 non-null object
In [12]: df.dtypes == 'object' #object is string data type
5 Age 714 non-null float64
6 SibSp 891 non-null int64
Out[12]: PassengerId False
7 Parch 891 non-null int64
Survived False
8 Ticket 891 non-null object
Pclass False
9 Fare 891 non-null float64
Name True
10 Cabin 204 non-null object
Sex True
11 Embarked 889 non-null object
Age False
dtypes: float64(2), int64(5), object(5)
SibSp False
memory usage: 83.7+ KB
Parch False
Ticket True
In [9]: df.describe() #statistical information about numerical column
Fare False
Cabin True
Out[9]: PassengerId Survived Pclass Age SibSp Parch
Embarked True
count 891.000000 891.000000 891.000000 714.000000 891.000000 891.000000 891.000000 dtype: bool

mean 446.000000 0.383838 2.308642 29.699118 0.523008 0.381594 In [16]: df.dtypes[df.dtypes == 'object']
std 257.353842 0.486592 0.836071 14.526497 1.102743 0.806057
Out[16]: Name object
min 1.000000 0.000000 1.000000 0.420000 0.000000 0.000000 Sex object
Ticket object
25% 223.500000 0.000000 2.000000 20.125000 0.000000 0.000000 Cabin object
Embarked object
50% 446.000000 0.000000 3.000000 28.000000 0.000000 0.000000
dtype: object
75% 668.500000 1.000000 3.000000 38.000000 1.000000 0.000000
In [17]: df.dtypes[df.dtypes == 'object'].index
max 891.000000 1.000000 3.000000 80.000000 8.000000 6.000000 512.329200
Out[17]: Index(['Name', 'Sex', 'Ticket', 'Cabin', 'Embarked'], dtype='object')
In [18]: df[df.dtypes[df.dtypes == 'object'].index] In [20]: df[df.dtypes[df.dtypes != 'object'].index].describe()

Out[18]: Name Sex Ticket Cabin Embarked Out[20]: PassengerId Survived Pclass Age SibSp Parch

0 Braund, Mr. Owen Harris male A/5 21171 NaN S count 891.000000 891.000000 891.000000 714.000000 891.000000 891.000000 891.0000

Cumings, Mrs. John Bradley mean 446.000000 0.383838 2.308642 29.699118 0.523008 0.381594
1 female PC 17599 C85 C
(Florence Briggs Th...
std 257.353842 0.486592 0.836071 14.526497 1.102743 0.806057
STON/O2.
2 Heikkinen, Miss. Laina female NaN S min 1.000000 0.000000 1.000000 0.420000 0.000000 0.000000
3101282

Futrelle, Mrs. Jacques Heath (Lily 25% 223.500000 0.000000 2.000000 20.125000 0.000000 0.000000
3 female 113803 C123 S
May Peel)
50% 446.000000 0.000000 3.000000 28.000000 0.000000 0.000000
4 Allen, Mr. William Henry male 373450 NaN S
75% 668.500000 1.000000 3.000000 38.000000 1.000000 0.000000
... ... ... ... ... ...
max 891.000000 1.000000 3.000000 80.000000 8.000000 6.000000 512.3292
886 Montvila, Rev. Juozas male 211536 NaN S

887 Graham, Miss. Margaret Edith female 112053 B42 S In [21]: df.describe()
Johnston, Miss. Catherine Helen
888 female W./C. 6607 NaN S Out[21]: PassengerId Survived Pclass Age SibSp Parch
"Carrie"

889 Behr, Mr. Karl Howell male 111369 C148 C count 891.000000 891.000000 891.000000 714.000000 891.000000 891.000000 891.0000

890 Dooley, Mr. Patrick male 370376 NaN Q mean 446.000000 0.383838 2.308642 29.699118 0.523008 0.381594

std 257.353842 0.486592 0.836071 14.526497 1.102743 0.806057


891 rows × 5 columns
min 1.000000 0.000000 1.000000 0.420000 0.000000 0.000000

In [19]: df[df.dtypes[df.dtypes != 'object'].index] 25% 223.500000 0.000000 2.000000 20.125000 0.000000 0.000000

50% 446.000000 0.000000 3.000000 28.000000 0.000000 0.000000


Out[19]: PassengerId Survived Pclass Age SibSp Parch Fare
75% 668.500000 1.000000 3.000000 38.000000 1.000000 0.000000
0 1 0 3 22.0 1 0 7.2500
max 891.000000 1.000000 3.000000 80.000000 8.000000 6.000000 512.3292
1 2 1 1 38.0 1 0 71.2833

2 3 1 3 26.0 0 0 7.9250
In [22]: df.describe(include = 'object')
3 4 1 1 35.0 1 0 53.1000
Out[22]: Name Sex Ticket Cabin Embarked
4 5 0 3 35.0 0 0 8.0500
count 891 891 891 204 889
... ... ... ... ... ... ... ...
unique 891 2 681 147 3
886 887 0 2 27.0 0 0 13.0000
top Braund, Mr. Owen Harris male 347082 B96 B98 S
887 888 1 1 19.0 0 0 30.0000
freq 1 577 7 4 644
888 889 0 3 NaN 1 2 23.4500

889 890 1 1 26.0 0 0 30.0000


In [23]: df.describe(include = 'all')
890 891 0 3 32.0 0 0 7.7500

891 rows × 7 columns


Out[23]: PassengerId Survived Pclass Name Sex Age SibSp Out[28]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket

count 891.000000 891.000000 891.000000 891 891 714.000000 891.000000 count 891 891 891 891 891 714.0 891 891 891

unique NaN NaN NaN 891 2 NaN NaN unique 891 2 3 891 2 88.0 7 7 681

Braund, Braund,
Mr. Mr.
top NaN NaN NaN male NaN NaN top 1 0 3 male 24.0 0 0 347082
Owen Owen
Harris Harris

freq NaN NaN NaN 1 577 NaN NaN freq 1 549 491 1 577 30.0 608 678 7

mean 446.000000 0.383838 2.308642 NaN NaN 29.699118 0.523008

std 257.353842 0.486592 0.836071 NaN NaN 14.526497 1.102743 In [32]: df[0:100:5]

min 1.000000 0.000000 1.000000 NaN NaN 0.420000 0.000000

25% 223.500000 0.000000 2.000000 NaN NaN 20.125000 0.000000

50% 446.000000 0.000000 3.000000 NaN NaN 28.000000 0.000000

75% 668.500000 1.000000 3.000000 NaN NaN 38.000000 1.000000

max 891.000000 1.000000 3.000000 NaN NaN 80.000000 8.000000

In [25]: df.describe() #five point summary

Out[25]: PassengerId Survived Pclass Age SibSp Parch

count 891.000000 891.000000 891.000000 714.000000 891.000000 891.000000 891.000000

mean 446.000000 0.383838 2.308642 29.699118 0.523008 0.381594

std 257.353842 0.486592 0.836071 14.526497 1.102743 0.806057

min 1.000000 0.000000 1.000000 0.420000 0.000000 0.000000

25% 223.500000 0.000000 2.000000 20.125000 0.000000 0.000000

50% 446.000000 0.000000 3.000000 28.000000 0.000000 0.000000

75% 668.500000 1.000000 3.000000 38.000000 1.000000 0.000000

max 891.000000 1.000000 3.000000 80.000000 8.000000 6.000000 512.329200

In [28]: df.astype('object').describe() #gives the statistocal information considering categorical column


Out[32]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket

Braund, Mr. Jenkin, Mr.


A/5 C.A
0 1 0 3 Owen male 22.0 1 0 70 71 0 2 Stephen male 32.0 0 0
21171 33111
Harris Curnow

Moran, Mr. Moen, Mr.


5 6 0 3 male NaN 0 0 330877
James 75 76 0 3 Sigurd male 25.0 0 0 348123
Hansen
Sandstrom,
Miss. Waelens,
10 11 1 3 female 4.0 1 1 PP 9549 80 81 0 3 male 22.0 0 0 345767
Marguerite Mr. Achille
Rut
Backstrom,
Hewlett, Mrs. Karl
Mrs. (Mary Alfred
15 16 1 2 female 55.0 0 0 248706 85 86 1 3 female 33.0 3 0 3101278
D (Maria
Kingcome) Mathilda
Gu...
Fynney, Mr.
20 21 0 2 male 35.0 0 0 239865
Joseph J Christmann,
90 91 0 3 male 29.0 0 0 343276
Mr. Emil
Asplund,
Mrs. Carl Shorney,
Oscar 95 96 0 3 Mr. Charles male NaN 0 0 374910
25 26 1 3 female 38.0 1 5 347077
(Selma Joseph
Augusta
Emilia...
In [35]: df['new_col'] = "pwskills"
Uruchurtu,
PC
30 31 0 1 Don. male 40.0 0 0
17601
Manuel E In [36]: df

Holverson,
Mr.
35 36 0 1 male 42.0 1 0 113789
Alexander
Oskar

Ahlin, Mrs.
Johan
40 41 0 3 (Johanna female 40.0 1 0 7546
Persdotter
Larsson)

Rogers, Mr.
S.C./A.4.
45 46 0 3 William male NaN 0 0
23567
John

Panula,
50 51 0 3 Master. male 7.0 4 1 3101295
Juha Niilo

Woolner,
55 56 1 1 male NaN 0 0 19947
Mr. Hugh

Sirayanian,
60 61 0 3 male 22.0 0 0 2669
Mr. Orsen

Moubarek,
65 66 1 3 Master. male NaN 1 1 2661
Gerios
Out[36]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket Out[38]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket

Braund, Braund,
A/5 A/5
0 1 0 3 Mr. Owen male 22.0 1 0 0 1 0 3 Mr. Owen male 22.0 1 0
21171 21171
Harris Harris

Cumings, Cumings,
Mrs. John Mrs. John
Bradley PC Bradley PC
1 2 1 1 female 38.0 1 0 1 2 1 1 female 38.0 1 0
(Florence 17599 (Florence 17599
Briggs Briggs
Th... Th...

Heikkinen, STON/ Heikkinen, STON/


2 3 1 3 Miss. female 26.0 0 0 O2. 2 3 1 3 Miss. female 26.0 0 0 O2.
Laina 3101282 Laina 3101282

Futrelle, Futrelle,
Mrs. Mrs.
Jacques Jacques
3 4 1 1 female 35.0 1 0 113803 3 4 1 1 female 35.0 1 0 113803
Heath Heath
(Lily May (Lily May
Peel) Peel)

Allen, Mr. Allen, Mr.


4 5 0 3 William male 35.0 0 0 373450 4 5 0 3 William male 35.0 0 0 373450
Henry Henry

... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...

Montvila, Montvila,
886 887 0 2 Rev. male 27.0 0 0 211536 886 887 0 2 Rev. male 27.0 0 0 211536
Juozas Juozas

Graham, Graham,
Miss. Miss.
887 888 1 1 female 19.0 0 0 112053 887 888 1 1 female 19.0 0 0 112053
Margaret Margaret
Edith Edith

Johnston, Johnston,
Miss. Miss.
W./C. W./C.
888 889 0 3 Catherine female NaN 1 2 888 889 0 3 Catherine female NaN 1 2
6607 6607
Helen Helen
"Carrie" "Carrie"

Behr, Mr. Behr, Mr.


889 890 1 1 Karl male 26.0 0 0 111369 889 890 1 1 Karl male 26.0 0 0 111369
Howell Howell

Dooley, Dooley,
890 891 0 3 male 32.0 0 0 370376 890 891 0 3 male 32.0 0 0 370376
Mr. Patrick Mr. Patrick

891 rows × 13 columns 891 rows × 14 columns

In [37]: df['family'] = df['SibSp'] + df['Parch'] In [40]: df.info()

In [38]: df
<class 'pandas.core.frame.DataFrame'> Out[44]: array([nan, 'C85', 'C123', 'E46', 'G6', 'C103', 'D56', 'A6',
RangeIndex: 891 entries, 0 to 890 'C23 C25 C27', 'B78', 'D33', 'B30', 'C52', 'B28', 'C83', 'F33',
Data columns (total 14 columns): 'F G73', 'E31', 'A5', 'D10 D12', 'D26', 'C110', 'B58 B60', 'E101',
# Column Non-Null Count Dtype 'F E69', 'D47', 'B86', 'F2', 'C2', 'E33', 'B19', 'A7', 'C49', 'F4',
--- ------ -------------- ----- 'A32', 'B4', 'B80', 'A31', 'D36', 'D15', 'C93', 'C78', 'D35',
0 PassengerId 891 non-null int64 'C87', 'B77', 'E67', 'B94', 'C125', 'C99', 'C118', 'D7', 'A19',
1 Survived 891 non-null int64 'B49', 'D', 'C22 C26', 'C106', 'C65', 'E36', 'C54',
2 Pclass 891 non-null int64 'B57 B59 B63 B66', 'C7', 'E34', 'C32', 'B18', 'C124', 'C91', 'E40',
3 Name 891 non-null object 'T', 'C128', 'D37', 'B35', 'E50', 'C82', 'B96 B98', 'E10', 'E44',
4 Sex 891 non-null object 'A34', 'C104', 'C111', 'C92', 'E38', 'D21', 'E12', 'E63', 'A14',
5 Age 714 non-null float64 'B37', 'C30', 'D20', 'B79', 'E25', 'D46', 'B73', 'C95', 'B38',
6 SibSp 891 non-null int64 'B39', 'B22', 'C86', 'C70', 'A16', 'C101', 'C68', 'A10', 'E68',
7 Parch 891 non-null int64 'B41', 'A20', 'D19', 'D50', 'D9', 'A23', 'B50', 'A26', 'D48',
8 Ticket 891 non-null object 'E58', 'C126', 'B71', 'B51 B53 B55', 'D49', 'B5', 'B20', 'F G63',
9 Fare 891 non-null float64 'C62 C64', 'E24', 'C90', 'C45', 'E8', 'B101', 'D45', 'C46', 'D30',
10 Cabin 204 non-null object 'E121', 'D11', 'E77', 'F38', 'B3', 'D6', 'B82 B84', 'D17', 'A36',
11 Embarked 889 non-null object 'B102', 'B69', 'E49', 'C47', 'D28', 'E17', 'A24', 'C50', 'B42',
12 new_col 891 non-null object 'C148'], dtype=object)
13 family 891 non-null int64
dtypes: float64(2), int64(6), object(6) In [45]: df['Cabin'].nunique()
memory usage: 97.6+ KB
Out[45]: 147
In [41]: pd.Categorical(df['Pclass']) #different categories of pclass

Out[41]: [3, 1, 3, 1, 3, ..., 2, 1, 3, 1, 3] In [46]: df['Cabin']


Length: 891
Categories (3, int64): [1, 2, 3] Out[46]: 0 NaN
1 C85
In [42]: pd.Categorical(df['Cabin']) 2 NaN
3 C123
Out[42]: [NaN, 'C85', NaN, 'C123', NaN, ..., NaN, 'B42', NaN, 'C148', NaN] 4 NaN
Length: 891 ...
Categories (147, object): ['A10', 'A14', 'A16', 'A19', ..., 'F38', 'F4', 'G 886 NaN
6', 'T'] 887 B42
888 NaN
In [44]: df['Cabin'].unique() 889 C148
890 NaN
Name: Cabin, Length: 891, dtype: object

In [47]: df['Cabin'].value_counts()

Out[47]: B96 B98 4


G6 4
C23 C25 C27 4
C22 C26 3
F33 3
..
E34 1
C7 1
C54 1
E36 1
C148 1
Name: Cabin, Length: 147, dtype: int64
In [48]: df Out[52]: PassengerId Survived Pclass Name Sex Age SibSp Parch Tick

Out[48]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket Palsson,
Master.
Braund, 7 8 0 3 male 2.00 3 1 349909
A/5 Gosta
0 1 0 3 Mr. Owen male 22.0 1 0 Leonard
21171
Harris
Sandstrom,
Cumings, Miss.
Mrs. John 10 11 1 3 female 4.00 1 1 PP 9549
Marguerite
Bradley PC Rut
1 2 1 1 female 38.0 1 0
(Florence 17599
Briggs Rice,
Th... 16 17 0 3 Master. male 2.00 4 1 382652
Eugene
Heikkinen, STON/
2 3 1 3 Miss. female 26.0 0 0 O2. Laroche,
Laina 3101282 Miss.
SC/P
43 44 1 2 Simonne female 3.00 1 2
Futrelle, 2123
Marie Anne
Mrs. Andree
Jacques
3 4 1 1 female 35.0 1 0 113803
Heath Skoog,
(Lily May 63 64 0 3 Master. male 4.00 3 2 347088
Peel) Harald

Allen, Mr. Caldwell,


4 5 0 3 William male 35.0 0 0 373450 78 79 1 2 Master. male 0.83 0 2 248738
Henry Alden Gates

... ... ... ... ... ... ... ... ... ... Andersson,
119 120 0 3 Miss. Ellis female 2.00 4 2 347082
Montvila, Anna Maria
886 887 0 2 Rev. male 27.0 0 0 211536
Juozas Panula,
164 165 0 3 Master. Eino male 1.00 4 1 3101295
Graham, Viljami
Miss.
887 888 1 1 female 19.0 0 0 112053
Margaret Rice,
Edith 171 172 0 3 Master. male 4.00 4 1 382652
Arthur
Johnston,
Miss. Johnson,
W./C.
888 889 0 3 Catherine female NaN 1 2 Miss.
6607 172 173 1 3 female 1.00 1 1 347742
Helen Eleanor
"Carrie" Ileen

Behr, Mr. Becker,


889 890 1 1 Karl male 26.0 0 0 111369 183 184 1 2 Master. male 1.00 2 1 230136
Howell Richard F

Dooley, Kink-
890 891 0 3 male 32.0 0 0 370376
Mr. Patrick Heilmann,
184 185 1 3 female 4.00 0 2 315153
Miss. Luise
Gretchen
891 rows × 14 columns
Navratil,
193 194 1 2 Master. male 3.00 1 1 230080
In [52]: #Q. How many passengers are less than 5 years old Michel M
df[df['Age'] < 5]
205 206 0 3 Strom, Miss. female 2.00 0 1 347054
PassengerId Survived Pclass Name Sex Age SibSp Parch Tick PassengerId Survived Pclass Name Sex Age SibSp Parch Tick

Telma Phyllis May


Matilda
Becker,
Asplund, 618 619 1 2 Miss. Marion female 4.00 2 1 230136
Master. Louise
261 262 1 3 male 3.00 4 2 347077
Edvin Rojj
Felix Skoog, Miss.
642 643 0 3 Margit female 2.00 3 2 347088
Allison, Elizabeth
297 298 0 1 Miss. Helen female 2.00 1 2 113781
Loraine Baclini,
644 645 1 3 Miss. female 0.75 2 1 2666
Allison, Eugenie
Master.
305 306 1 1 male 0.92 1 2 113781 Karun, Miss.
Hudson 691 692 1 3 female 4.00 0 1 349256
Trevor Manca

Navratil, Wells, Miss.


750 751 1 2 female 4.00 1 1 29103
Master. Joan
340 341 1 2 male 2.00 1 1 230080
Edmond
Roger Hamalainen,
755 756 1 2 male 0.67 1 1 250649
Master. Viljo
Coutts,
Master. Dean,
348 349 1 3 male 3.00 1 1 Master.
William Loch 37671 788 789 1 3 male 1.00 1 2 C.A. 2315
"William" Bertram
Vere
Palsson,
374 375 0 3 Miss. Stina female 3.00 3 1 349909 Thomas,
Viola Master.
803 804 1 3 male 0.42 0 1 2625
Assad
Nakid, Miss. Alexander
381 382 1 3 Maria female 1.00 0 2 2653
("Mary") Panula,
Master.
824 825 0 3 male 2.00 4 1 3101295
Goodwin, Urho
Master. Abraham
386 387 0 3 male 1.00 5 2 CA 2144
Sidney
Leonard Mallet,
S.C./P
827 828 1 2 Master. male 1.00 0 2
2079
Richards, Andre
Master.
407 408 1 2 male 3.00 1 1 29106 Richards,
William
Rowe Master.
831 832 1 2 male 0.83 1 1 29106
George
Dodge, Sibley
445 446 1 1 Master. male 4.00 0 2 33638
Washington Andersson,
Master.
850 851 0 3 male 4.00 4 2 347082
Baclini, Sigvard
Miss. Harald Elias
469 470 1 3 female 0.75 2 1 2666
Helene
Barbara Johnson,
Master.
869 870 1 3 male 4.00 1 1 347742
Hirvonen, Harold
479 480 1 3 Miss. Hildur female 2.00 0 1 3101298 Theodor
E

530 531 1 2 Quick, Miss. female 2.00 1 1 26360 In [53]: len(df[df['Age'] < 5])
Out[53]: 40 Out[56]: ['Palsson, Master. Gosta Leonard',
'Sandstrom, Miss. Marguerite Rut',
In [55]: df[df['Age'] < 5].Name 'Rice, Master. Eugene',
'Laroche, Miss. Simonne Marie Anne Andree',
Out[55]: 7 Palsson, Master. Gosta Leonard 'Skoog, Master. Harald',
10 Sandstrom, Miss. Marguerite Rut 'Caldwell, Master. Alden Gates',
16 Rice, Master. Eugene 'Andersson, Miss. Ellis Anna Maria',
43 Laroche, Miss. Simonne Marie Anne Andree 'Panula, Master. Eino Viljami',
63 Skoog, Master. Harald 'Rice, Master. Arthur',
78 Caldwell, Master. Alden Gates 'Johnson, Miss. Eleanor Ileen',
119 Andersson, Miss. Ellis Anna Maria 'Becker, Master. Richard F',
164 Panula, Master. Eino Viljami 'Kink-Heilmann, Miss. Luise Gretchen',
171 Rice, Master. Arthur 'Navratil, Master. Michel M',
172 Johnson, Miss. Eleanor Ileen 'Strom, Miss. Telma Matilda',
183 Becker, Master. Richard F 'Asplund, Master. Edvin Rojj Felix',
184 Kink-Heilmann, Miss. Luise Gretchen 'Allison, Miss. Helen Loraine',
193 Navratil, Master. Michel M 'Allison, Master. Hudson Trevor',
205 Strom, Miss. Telma Matilda 'Navratil, Master. Edmond Roger',
261 Asplund, Master. Edvin Rojj Felix 'Coutts, Master. William Loch "William"',
297 Allison, Miss. Helen Loraine 'Palsson, Miss. Stina Viola',
305 Allison, Master. Hudson Trevor 'Nakid, Miss. Maria ("Mary")',
340 Navratil, Master. Edmond Roger 'Goodwin, Master. Sidney Leonard',
348 Coutts, Master. William Loch "William" 'Richards, Master. William Rowe',
374 Palsson, Miss. Stina Viola 'Dodge, Master. Washington',
381 Nakid, Miss. Maria ("Mary") 'Baclini, Miss. Helene Barbara',
386 Goodwin, Master. Sidney Leonard 'Hirvonen, Miss. Hildur E',
407 Richards, Master. William Rowe 'Quick, Miss. Phyllis May',
445 Dodge, Master. Washington 'Becker, Miss. Marion Louise',
469 Baclini, Miss. Helene Barbara 'Skoog, Miss. Margit Elizabeth',
479 Hirvonen, Miss. Hildur E 'Baclini, Miss. Eugenie',
530 Quick, Miss. Phyllis May 'Karun, Miss. Manca',
618 Becker, Miss. Marion Louise 'Wells, Miss. Joan',
642 Skoog, Miss. Margit Elizabeth 'Hamalainen, Master. Viljo',
644 Baclini, Miss. Eugenie 'Dean, Master. Bertram Vere',
691 Karun, Miss. Manca 'Thomas, Master. Assad Alexander',
750 Wells, Miss. Joan 'Panula, Master. Urho Abraham',
755 Hamalainen, Master. Viljo 'Mallet, Master. Andre',
788 Dean, Master. Bertram Vere 'Richards, Master. George Sibley',
803 Thomas, Master. Assad Alexander 'Andersson, Master. Sigvard Harald Elias',
824 Panula, Master. Urho Abraham 'Johnson, Master. Harold Theodor']
827 Mallet, Master. Andre
831 Richards, Master. George Sibley In [58]: #how many person are less than 18 years old
850 Andersson, Master. Sigvard Harald Elias
869 Johnson, Master. Harold Theodor len(df[df['Age'] > 18])
Name: Name, dtype: object
Out[58]: 575
In [56]: list(df[df['Age'] < 5].Name)
In [60]: df['Fare'].mean()

Out[60]: 32.204207968574636

In [63]: #Q. How many passengers hav epaid less than avg fare
df[df['Fare'] < df['Fare'].mean()] In [69]: df[df['Sex'] == "male"]

Out[63]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket Out[69]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket

Braund, Braund,
A/5
0 1 0 3 Mr. Owen male 22.0 1 0 0 1 0 3 Mr. Owen male 22.0 1 0 A/5 21171
21171
Harris Harris

Heikkinen, STON/ Allen, Mr.


2 3 1 3 Miss. female 26.0 0 0 O2. 4 5 0 3 William male 35.0 0 0 373450
Laina 3101282 Henry

Allen, Mr. Moran,


5 6 0 3 male NaN 0 0 330877
4 5 0 3 William male 35.0 0 0 373450 Mr. James
Henry
McCarthy,
Moran, Mr. 6 7 0 1 Mr. male 54.0 0 0 17463
5 6 0 3 male NaN 0 0 330877
James Timothy J

Palsson, Palsson,
Master. Master.
7 8 0 3 male 2.0 3 1 349909 7 8 0 3 male 2.0 3 1 349909
Gosta Gosta
Leonard Leonard

... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...

Montvila, Banfield,
886 887 0 2 Rev. male 27.0 0 0 211536 Mr. C.A./SOTON
883 884 0 2 male 28.0 0 0
Juozas Frederick 34068
James
Graham,
Miss. Sutehall,
887 888 1 1 female 19.0 0 0 112053 SOTON/OQ
Margaret 884 885 0 3 Mr. Henry male 25.0 0 0
392076
Edith Jr

Johnston, Montvila,
Miss. 886 887 0 2 Rev. male 27.0 0 0 211536
W./C.
888 889 0 3 Catherine female NaN 1 2 Juozas
6607
Helen
"Carrie" Behr, Mr.
889 890 1 1 Karl male 26.0 0 0 111369
Behr, Mr. Howell
889 890 1 1 Karl male 26.0 0 0 111369
Howell Dooley,
890 891 0 3 Mr. male 32.0 0 0 370376
Dooley, Patrick
890 891 0 3 male 32.0 0 0 370376
Mr. Patrick
577 rows × 14 columns
680 rows × 14 columns

In [70]: len(df[df['Sex'] == "male"])


In [64]: len(df[df['Fare'] < df['Fare'].mean()])
Out[70]: 577
Out[64]: 680
In [71]: len(df[df['Sex'] == "female"])
In [67]: #how many passengers paid o fare
len(df[df['Fare'] == 0]) Out[71]: 314

Out[67]: 15
In [73]: df['Sex'].value_counts(normalize = True)
Out[73]: male 0.647587 Out[75]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket
female 0.352413
Name: Sex, dtype: float64 Cumings,
Mrs. John
Bradley PC
In [75]: #how many passengers of class 1 1 2 1 1 female 38.0 1 0
(Florence 17599
Briggs
df[df['Pclass'] == 1] Th...

Futrelle,
Mrs.
3 4 1 1 Jacques female 35.0 1 0 113803
Heath (Lily
May Peel)

McCarthy,
6 7 0 1 Mr. male 54.0 0 0 17463
Timothy J

Bonnell,
11 12 1 1 Miss. female 58.0 0 0 113783
Elizabeth

Sloper, Mr.
23 24 1 1 William male 28.0 0 0 113788
Thompson

... ... ... ... ... ... ... ... ... ...

Beckwith,
Mrs.
Richard
871 872 1 1 female 47.0 1 1 11751
Leonard
(Sallie
Monypeny)

Carlsson,
872 873 0 1 Mr. Frans male 33.0 0 0 695
Olof

Potter,
Mrs.
Thomas Jr
879 880 1 1 female 56.0 0 1 11767
(Lily
Alexenia
Wilson)

Graham,
Miss.
887 888 1 1 female 19.0 0 0 112053
Margaret
Edith

Behr, Mr.
889 890 1 1 Karl male 26.0 0 0 111369
Howell

216 rows × 14 columns

In [77]: #how many passenger survived


Out[77]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket
df[df['Survived'] == 1]
Cumings,
Mrs. John
Bradley PC
1 2 1 1 female 38.0 1 0
(Florence 17599
Briggs
Th...

Heikkinen, STON/
2 3 1 3 Miss. female 26.0 0 0 O2.
Laina 3101282

Futrelle,
Mrs.
Jacques
3 4 1 1 female 35.0 1 0 113803
Heath
(Lily May
Peel)

Johnson,
Mrs.
Oscar W
8 9 1 3 female 27.0 0 2 347742
(Elisabeth
Vilhelmina
Berg)

Nasser,
Mrs.
9 10 1 2 Nicholas female 14.0 1 0 237736
(Adele
Achem)

... ... ... ... ... ... ... ... ... ...

Najib,
Miss.
875 876 1 3 Adele female 15.0 0 0 2667
Kiamie
"Jane"

Potter,
Mrs.
Thomas Jr
879 880 1 1 female 56.0 0 1 11767
(Lily
Alexenia
Wilson)

Shelley,
Mrs.
William
880 881 1 2 female 25.0 0 1 230433
(Imanita
Parrish
Hall)

Graham,
Miss.
887 888 1 1 female 19.0 0 0 112053
Margaret
Edith
PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket Out[87]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket

Behr, Mr. Cumings,


889 890 1 1 Karl male 26.0 0 0 111369 Mrs. John
Howell Bradley PC
1 2 1 1 female 38.0 1 0
(Florence 17599
Briggs
342 rows × 14 columns
Th...

Futrelle,
In [78]: len(df[df['Survived'] == 1]) Mrs.
3 4 1 1 Jacques female 35.0 1 0 113803
Out[78]: 342 Heath (Lily
May Peel)

In [80]: df['Survived'].value_counts(normalize = True) Spencer,


Mrs.
Out[80]: 0 0.616162 William PC
31 32 1 1 female NaN 1 0
1 0.383838 Augustus 17569
Name: Survived, dtype: float64 (Marie
Eugenie)
In [82]: #how many females paid more than avg fare Laroche,
Miss.
SC/
In [83]: df['Sex'] == 'Female' Simonne
43 44 1 2 female 3.0 1 2 Paris
Marie
2123
Anne
Out[83]: 0 False
Andree
1 False
2 False Harper,
3 False Mrs. Henry
PC
4 False 52 53 1 1 Sleeper female 49.0 1 0
17572
... (Myna
886 False Haxtun)
887 False ... ... ... ... ... ... ... ... ... ...
888 False
889 False Lines,
PC
890 False 853 854 1 1 Miss. Mary female 16.0 0 1
17592
Name: Sex, Length: 891, dtype: bool Conover

Wick, Mrs.
In [84]: df['Fare'].mean() George
856 857 1 1 Dennick female 45.0 1 1 36928
Out[84]: 32.204207968574636 (Mary
Hitchcock)
In [87]: df[(df['Sex'] == 'female') & (df['Fare'] > df['Fare'].mean())] Sage,
Miss.
CA.
863 864 0 3 Dorothy female NaN 8 2
2343
Edith
"Dolly"

Beckwith,
Mrs.
Richard
871 872 1 1 female 47.0 1 1 11751
Leonard
(Sallie
Monypeny)
PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket Out[95]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket

Potter, Ward,
PC
Mrs. 258 259 1 1 Miss. female 35.0 0 0 512.3292
17755
Thomas Jr Anna
879 880 1 1 female 56.0 0 1 11767
(Lily
Alexenia Cardeza,
Wilson) Mr.
PC
679 680 1 1 Thomas male 36.0 0 1 512.3292
17755
Drake
104 rows × 14 columns Martinez

Lesurer,
In [88]: len(df[(df['Sex'] == 'female') & (df['Fare'] > df['Fare'].mean())]) Mr. PC
737 738 1 1 male 35.0 0 0 512.3292
Gustave 17755
Out[88]: 104 J

In [89]: len(df[(df['Sex'] == 'male') & (df['Fare'] > df['Fare'].mean())])


In [96]: df[df['Fare'] == max(df.Fare)].Name

Out[89]: 107
Out[96]: 258 Ward, Miss. Anna
679 Cardeza, Mr. Thomas Drake Martinez
In [90]: import numpy as np 737 Lesurer, Mr. Gustave J
np.mean(df.Fare) Name: Name, dtype: object

Out[90]: 32.204207968574636 In [98]: df.Age

In [91]: df.Fare.mean() Out[98]: 0 22.0


1 38.0
Out[91]: 32.204207968574636 2 26.0
3 35.0
4 35.0
In [92]: max(df.Fare)
...
886 27.0
Out[92]: 512.3292
887 19.0
888 NaN
In [93]: min(df['Fare']) 889 26.0
890 32.0
Out[93]: 0.0 Name: Age, Length: 891, dtype: float64

In [95]: df[df['Fare'] == max(df.Fare)] In [ ]:


In [37]: import pandas as pd In [39]: df[0:100]

df = pd.read_csv("https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv"
Out[39]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket

Braund, Mr. A/5


In [38]: df 0 1 0 3 male 22.0 1 0
Owen Harris 21171

Out[38]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket Cumings,
Mrs. John
PC
Braund, 1 2 1 1 Bradley female 38.0 1 0
A/5 17599
0 1 0 3 Mr. Owen male 22.0 1 0 (Florence
21171
Harris Briggs Th...

Cumings, STON/
Heikkinen,
Mrs. John 2 3 1 3 female 26.0 0 0 O2.
Miss. Laina
Bradley PC 3101282
1 2 1 1 female 38.0 1 0
(Florence 17599
Briggs Futrelle, Mrs.
Th... Jacques
3 4 1 1 female 35.0 1 0 113803
Heath (Lily
Heikkinen, STON/ May Peel)
2 3 1 3 Miss. female 26.0 0 0 O2.
Laina 3101282 Allen, Mr.
4 5 0 3 William male 35.0 0 0 373450
Futrelle, Henry
Mrs.
Jacques ... ... ... ... ... ... ... ... ...
3 4 1 1 female 35.0 1 0 113803
Heath
(Lily May Shorney, Mr.
Peel) 95 96 0 3 Charles male NaN 0 0 374910
Joseph
Allen, Mr.
4 5 0 3 William male 35.0 0 0 373450 Goldschmidt, PC
96 97 0 1 male 71.0 0 0
Henry Mr. George B 17754

... ... ... ... ... ... ... ... ... ... Greenfield,
PC
97 98 1 1 Mr. William male 23.0 0 1
17759
Montvila, Bertram
886 887 0 2 Rev. male 27.0 0 0 211536
Juozas Doling, Mrs.
98 99 1 2 John T (Ada female 34.0 0 1 231919
Graham, Julia Bone)
Miss.
887 888 1 1 female 19.0 0 0 112053 Kantor, Mr.
Margaret 99 100 0 2 male 34.0 1 0 244367
Edith Sinai

Johnston,
100 rows × 12 columns
Miss.
W./C.
888 889 0 3 Catherine female NaN 1 2
6607
Helen
"Carrie" In [40]: #access rows and column of dataframe >>implicit/internal/integer indexing, explicit/na

Behr, Mr. In [41]: df.iloc[0:2] #start from o and go till 1


889 890 1 1 Karl male 26.0 0 0 111369
Howell

Dooley,
890 891 0 3 male 32.0 0 0 370376
Mr. Patrick

891 rows × 12 columns


Out[41]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket ---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
Braund, Cell In[43], line 1
A/5
0 1 0 3 Mr. Owen male 22.0 1 0 7.2500 ----> 1 df.iloc[0:2, ['Name', 'Parch']] #it will throw an error
21171
Harris

Cumings, File /opt/conda/lib/python3.10/site-packages/pandas/core/indexing.py:1067, in


Mrs. John _LocationIndexer.__getitem__(self, key)
Bradley PC 1065 if self._is_scalar_access(key):
1 2 1 1 female 38.0 1 0 71.2833
(Florence 17599 1066 return self.obj._get_value(*key, takeable=self._takeable)
Briggs -> 1067 return self._getitem_tuple(key)
Th... 1068 else:
1069 # we by definition only have the 0th axis
1070 axis = self.axis or 0
In [42]: df.loc[0:2] #loc is used for named indexes, iloc is used for integer indexes
File /opt/conda/lib/python3.10/site-packages/pandas/core/indexing.py:1563, in
Out[42]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket _iLocIndexer._getitem_tuple(self, tup)
Braund, 1561 def _getitem_tuple(self, tup: tuple):
A/5 -> 1563 tup = self._validate_tuple_indexer(tup)
0 1 0 3 Mr. Owen male 22.0 1 0
21171 1564 with suppress(IndexingError):
Harris
1565 return self._getitem_lowerdim(tup)
Cumings,
Mrs. John File /opt/conda/lib/python3.10/site-packages/pandas/core/indexing.py:873, in _L
Bradley PC
1 2 1 1 female 38.0 1 0 ocationIndexer._validate_tuple_indexer(self, key)
(Florence 17599
Briggs 871 for i, k in enumerate(key):
Th... 872 try:
--> 873 self._validate_key(k, i)
Heikkinen, STON/ 874 except ValueError as err:
2 3 1 3 Miss. female 26.0 0 0 O2. 875 raise ValueError(
Laina 3101282 876 "Location based indexing can only have "
877 f"[{self._valid_types}] types"
878 ) from err
In [43]: df.iloc[0:2, ['Name', 'Parch']] #it will throw an error
File /opt/conda/lib/python3.10/site-packages/pandas/core/indexing.py:1477, in
_iLocIndexer._validate_key(self, key, axis)
1475 # check that the key has a numeric dtype
1476 if not is_numeric_dtype(arr.dtype):
-> 1477 raise IndexError(f".iloc requires numeric indexers, got {arr}")
1479 # check that the key does not exceed the maximum size of the index
1480 if len(arr) and (arr.max() >= len_axis or arr.min() < -len_axis):

IndexError: .iloc requires numeric indexers, got ['Name' 'Parch']

In [44]: df.loc[0:2, ['Name', 'Parch']]

Out[44]: Name Parch

0 Braund, Mr. Owen Harris 0

1 Cumings, Mrs. John Bradley (Florence Briggs Th... 0

2 Heikkinen, Miss. Laina 0

In [45]: df.iloc[0:2, 3:6]


Out[45]: Name Sex Age In [54]: s1 = pd.Series(list(df['Name'][5:8]), index=['a', 'b', 'c'])
s1
0 Braund, Mr. Owen Harris male 22.0
Out[54]: a Moran, Mr. James
1 Cumings, Mrs. John Bradley (Florence Briggs Th... female 38.0 b McCarthy, Mr. Timothy J
c Palsson, Master. Gosta Leonard
dtype: object
In [46]: list(df['Name'][2:5])
In [55]: s
Out[46]: ['Heikkinen, Miss. Laina',
'Futrelle, Mrs. Jacques Heath (Lily May Peel)', Out[55]: a Heikkinen, Miss. Laina
'Allen, Mr. William Henry'] b Futrelle, Mrs. Jacques Heath (Lily May Peel)
c Allen, Mr. William Henry
In [47]: s = pd.Series(list(df['Name'][2:5]), index=['a', 'b', 'c']) dtype: object

In [48]: s In [56]: s+s1

Out[48]: a Heikkinen, Miss. Laina Out[56]: a Heikkinen, Miss. LainaMoran, Mr. James
b Futrelle, Mrs. Jacques Heath (Lily May Peel) b Futrelle, Mrs. Jacques Heath (Lily May Peel)Mc...
c Allen, Mr. William Henry c Allen, Mr. William HenryPalsson, Master. Gosta...
dtype: object dtype: object

In [49]: s1 = pd.Series(list(df['Name'][5:8])) In [57]: df

In [50]: s

Out[50]: a Heikkinen, Miss. Laina


b Futrelle, Mrs. Jacques Heath (Lily May Peel)
c Allen, Mr. William Henry
dtype: object

In [51]: "pw"+"skills"

Out[51]: 'pwskills'

In [52]: s+s1 #series and dataframe cannot be concatenated

Out[52]: a NaN
b NaN
c NaN
0 NaN
1 NaN
2 NaN
dtype: object

In [53]: #if you keep the index same, then for series concatenation can happen

Out[53]: a Heikkinen, Miss. Laina


b Futrelle, Mrs. Jacques Heath (Lily May Peel)
c Allen, Mr. William Henry
dtype: object
Out[57]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket Out[59]: Survived Pclass Name Sex Age SibSp Parch Ticket Fare Cabin

Braund, Braund,
A/5 A/5
0 1 0 3 Mr. Owen male 22.0 1 0 0 0 3 Mr. Owen male 22.0 1 0 7.2500 NaN
21171 21171
Harris Harris

Cumings, Cumings,
Mrs. John Mrs. John
Bradley PC Bradley PC
1 2 1 1 female 38.0 1 0 1 1 1 female 38.0 1 0 71.2833 C85
(Florence 17599 (Florence 17599
Briggs Briggs
Th... Th...

Heikkinen, STON/ Heikkinen, STON/


2 3 1 3 Miss. female 26.0 0 0 O2. 2 1 3 Miss. female 26.0 0 0 O2. 7.9250 NaN
Laina 3101282 Laina 3101282

Futrelle, Futrelle,
Mrs. Mrs.
Jacques Jacques
3 4 1 1 female 35.0 1 0 113803 3 1 1 female 35.0 1 0 113803 53.1000 C123
Heath Heath
(Lily May (Lily May
Peel) Peel)

Allen, Mr. Allen, Mr.


4 5 0 3 William male 35.0 0 0 373450 4 0 3 William male 35.0 0 0 373450 8.0500 NaN
Henry Henry

... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...

Montvila, Montvila,
886 887 0 2 Rev. male 27.0 0 0 211536 886 0 2 Rev. male 27.0 0 0 211536 13.0000 NaN
Juozas Juozas

Graham, Graham,
Miss. Miss.
887 888 1 1 female 19.0 0 0 112053 887 1 1 female 19.0 0 0 112053 30.0000 B42
Margaret Margaret
Edith Edith

Johnston, Johnston,
Miss. Miss.
W./C. W./C.
888 889 0 3 Catherine female NaN 1 2 888 0 3 Catherine female NaN 1 2 23.4500 NaN
6607 6607
Helen Helen
"Carrie" "Carrie"

Behr, Mr. Behr, Mr.


889 890 1 1 Karl male 26.0 0 0 111369 889 1 1 Karl male 26.0 0 0 111369 30.0000 C148
Howell Howell

Dooley, Dooley,
890 891 0 3 male 32.0 0 0 370376 890 0 3 male 32.0 0 0 370376 7.7500 NaN
Mr. Patrick Mr. Patrick

891 rows × 12 columns 891 rows × 11 columns

In [58]: df.drop('PassengerId', axis=1, inplace=True)#axis =0>> rows, axis = 1 column, inplace =True means
In [61]:
modify df.drop(1,
the original
inplace=True)
dataframe

In [59]: df In [62]: df
Out[62]: Survived Pclass Name Sex Age SibSp Parch Ticket Fare Cabin Out[63]: Survived Pclass Name Sex Age SibSp Parch Ticket Fare Cabin

Braund, Braund,
A/5 A/5
0 0 3 Mr. Owen male 22.0 1 0 7.2500 NaN 0 0 3 Mr. Owen male 22.0 1 0 7.2500 NaN
21171 21171
Harris Harris

Heikkinen, STON/ Heikkinen, STON/


2 1 3 Miss. female 26.0 0 0 O2. 7.9250 NaN 1 1 3 Miss. female 26.0 0 0 O2. 7.9250 NaN
Laina 3101282 Laina 3101282

Futrelle, Futrelle,
Mrs. Mrs.
Jacques Jacques
3 1 1 female 35.0 1 0 113803 53.1000 C123 2 1 1 female 35.0 1 0 113803 53.1000 C123
Heath Heath
(Lily May (Lily May
Peel) Peel)

Allen, Mr. Allen, Mr.


4 0 3 William male 35.0 0 0 373450 8.0500 NaN 3 0 3 William male 35.0 0 0 373450 8.0500 NaN
Henry Henry

Moran, Mr. Moran, Mr.


5 0 3 male NaN 0 0 330877 8.4583 NaN 4 0 3 male NaN 0 0 330877 8.4583 NaN
James James

... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...

Montvila, Montvila,
886 0 2 Rev. male 27.0 0 0 211536 13.0000 NaN 885 0 2 Rev. male 27.0 0 0 211536 13.0000 NaN
Juozas Juozas

Graham, Graham,
Miss. Miss.
887 1 1 female 19.0 0 0 112053 30.0000 B42 886 1 1 female 19.0 0 0 112053 30.0000 B42
Margaret Margaret
Edith Edith

Johnston, Johnston,
Miss. Miss.
W./C. W./C.
888 0 3 Catherine female NaN 1 2 23.4500 NaN 887 0 3 Catherine female NaN 1 2 23.4500 NaN
6607 6607
Helen Helen
"Carrie" "Carrie"

Behr, Mr. Behr, Mr.


889 1 1 Karl male 26.0 0 0 111369 30.0000 C148 888 1 1 Karl male 26.0 0 0 111369 30.0000 C148
Howell Howell

Dooley, Dooley,
890 0 3 male 32.0 0 0 370376 7.7500 NaN 889 0 3 male 32.0 0 0 370376 7.7500 NaN
Mr. Patrick Mr. Patrick

890 rows × 11 columns 890 rows × 11 columns

In [63]: df.reset_index(drop = True) In [65]: df.set_index('Name', inplace=True)

In [67]: df.loc['Braund, Mr. Owen Harris']


Out[67]: Survived 0 Out[70]: Name Survived Pclass Sex Age SibSp Parch Ticket Fare Cabin
Pclass 3
Sex male Braund,
A/5
0 Mr. Owen 0 3 male 22.0 1 0 7.2500 NaN
Age 22.0 21171
Harris
SibSp 1
Parch 0 Heikkinen, STON/
Ticket A/5 21171 1 Miss. 1 3 female 26.0 0 0 O2. 7.9250 NaN
Fare 7.25 Laina 3101282
Cabin NaN
Futrelle,
Embarked S
Mrs.
Name: Braund, Mr. Owen Harris, dtype: object Jacques
2 1 1 female 35.0 1 0 113803 53.1000 C123
Heath
In [69]: df.reset_index(inplace=True) (Lily May
Peel)
In [70]: df
Allen, Mr.
3 William 0 3 male 35.0 0 0 373450 8.0500 NaN
Henry

Moran, Mr.
4 0 3 male NaN 0 0 330877 8.4583 NaN
James

... ... ... ... ... ... ... ... ... ...

Montvila,
885 Rev. 0 2 male 27.0 0 0 211536 13.0000 NaN
Juozas

Graham,
Miss.
886 1 1 female 19.0 0 0 112053 30.0000 B42
Margaret
Edith

Johnston,
Miss.
W./C.
887 Catherine 0 3 female NaN 1 2 23.4500 NaN
6607
Helen
"Carrie"

Behr, Mr.
888 Karl 1 1 male 26.0 0 0 111369 30.0000 C148
Howell

Dooley,
889 0 3 male 32.0 0 0 370376 7.7500 NaN
Mr. Patrick

890 rows × 11 columns

In [71]: d = {'key1': [2, 3, 4, 5],


'key2': [4, 5, 6, 7],
'key3': [2, 3, 4, 5]}

In [72]: d

Out[72]: {'key1': [2, 3, 4, 5], 'key2': [4, 5, 6, 7], 'key3': [2, 3, 4, 5]}
In [73]: pd.DataFrame(d) Out[78]: taxonomy_id name parent_id parent_name

Out[73]: key1 key2 key3 0 101 Emergency NaN NaN

0 2 4 2 1 101-01 Disaster Response 101 Emergency

1 3 5 3 2 101-02 Emergency Cash 101 Emergency

2 4 6 4 3 101-02-01 Help Pay for Food 101-02 Emergency Cash

3 5 7 5 4 101-02-02 Help Pay for Healthcare 101-02 Emergency Cash

... ... ... ... ...


In [74]: d = {'key1': (2, 3, 4, 5), 285 111-01-07 Workplace Rights 111-01 Advocacy & Legal Aid
'key2': (4, 5, 6, 7),
'key3': (2, 3, 4, 5)} 286 111-02 Mediation 111 Legal

287 111-03 Notary 111 Legal


In [75]: d
288 111-04 Representation 111 Legal
Out[75]: {'key1': (2, 3, 4, 5), 'key2': (4, 5, 6, 7), 'key3': (2, 3, 4, 5)}
289 111-05 Translation & Interpretation 111 Legal

In [76]: pd.DataFrame(d)
290 rows × 4 columns
Out[76]: key1 key2 key3

0 2 4 2 In [79]: df1.shape

1 3 5 3 Out[79]: (290, 4)

2 4 6 4
In [81]: df1.describe()
3 5 7 5
Out[81]: taxonomy_id name parent_id parent_name

In [77]: df1 = pd.read_csv("taxonomy.csv") count 290 290 279 279

unique 290 183 60 50


In [78]: df1
top 101 Nursing Home 106-06-07 Health Education

freq 1 4 11 15

In [82]: df1.info()

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 290 entries, 0 to 289
Data columns (total 4 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 taxonomy_id 290 non-null object
1 name 290 non-null object
2 parent_id 279 non-null object
3 parent_name 279 non-null object
dtypes: object(4)
memory usage: 9.2+ KB
In [83]: df1 Out[87]: taxonomy_id name parent_id parent_name

Out[83]: taxonomy_id name parent_id parent_name 0 101 Emergency NaN NaN

0 101 Emergency NaN NaN 1 101-01 Disaster Response 101 Emergency

1 101-01 Disaster Response 101 Emergency 2 101-02 Emergency Cash 101 Emergency

2 101-02 Emergency Cash 101 Emergency 3 101-02-01 Help Pay for Food 101-02 Emergency Cash

3 101-02-01 Help Pay for Food 101-02 Emergency Cash 4 101-02-02 Help Pay for Healthcare 101-02 Emergency Cash

4 101-02-02 Help Pay for Healthcare 101-02 Emergency Cash ... ... ... ... ...

... ... ... ... ... 285 111-01-07 Workplace Rights 111-01 Advocacy & Legal Aid

285 111-01-07 Workplace Rights 111-01 Advocacy & Legal Aid 286 111-02 Mediation 111 Legal

286 111-02 Mediation 111 Legal 287 111-03 Notary 111 Legal

287 111-03 Notary 111 Legal 288 111-04 Representation 111 Legal

288 111-04 Representation 111 Legal 289 111-05 Translation & Interpretation 111 Legal

289 111-05 Translation & Interpretation 111 Legal


290 rows × 4 columns

290 rows × 4 columns


In [88]: df1.dropna() #remove null values row wise

In [85]: df1.isnull().sum() Out[88]: taxonomy_id name parent_id parent_name

Out[85]: taxonomy_id 0 1 101-01 Disaster Response 101 Emergency


name 0
parent_id 11 2 101-02 Emergency Cash 101 Emergency
parent_name 11 3 101-02-01 Help Pay for Food 101-02 Emergency Cash
dtype: int64
4 101-02-02 Help Pay for Healthcare 101-02 Emergency Cash
In [87]: df1
5 101-02-03 Help Pay for Housing 101-02 Emergency Cash

... ... ... ... ...

285 111-01-07 Workplace Rights 111-01 Advocacy & Legal Aid

286 111-02 Mediation 111 Legal

287 111-03 Notary 111 Legal

288 111-04 Representation 111 Legal

289 111-05 Translation & Interpretation 111 Legal

279 rows × 4 columns

In [91]: df1.dropna(axis = 1)
Out[91]: taxonomy_id name In [95]: df1.fillna("somevalue")

0 101 Emergency Out[95]: taxonomy_id name parent_id parent_name

1 101-01 Disaster Response 0 101 Emergency somevalue somevalue

2 101-02 Emergency Cash 1 101-01 Disaster Response 101 Emergency

3 101-02-01 Help Pay for Food 2 101-02 Emergency Cash 101 Emergency

4 101-02-02 Help Pay for Healthcare 3 101-02-01 Help Pay for Food 101-02 Emergency Cash

... ... ... 4 101-02-02 Help Pay for Healthcare 101-02 Emergency Cash

285 111-01-07 Workplace Rights ... ... ... ... ...

286 111-02 Mediation 285 111-01-07 Workplace Rights 111-01 Advocacy & Legal Aid

287 111-03 Notary 286 111-02 Mediation 111 Legal

288 111-04 Representation 287 111-03 Notary 111 Legal

289 111-05 Translation & Interpretation 288 111-04 Representation 111 Legal

289 111-05 Translation & Interpretation 111 Legal


290 rows × 2 columns

290 rows × 4 columns


In [92]: df1[['name']].dropna(axis=1) #for one column

Out[92]: name In [96]: df1.fillna(0)

0 Emergency Out[96]: taxonomy_id name parent_id parent_name

1 Disaster Response 0 101 Emergency 0 0

2 Emergency Cash 1 101-01 Disaster Response 101 Emergency

3 Help Pay for Food 2 101-02 Emergency Cash 101 Emergency

4 Help Pay for Healthcare 3 101-02-01 Help Pay for Food 101-02 Emergency Cash

... ... 4 101-02-02 Help Pay for Healthcare 101-02 Emergency Cash

285 Workplace Rights ... ... ... ... ...

286 Mediation 285 111-01-07 Workplace Rights 111-01 Advocacy & Legal Aid

287 Notary 286 111-02 Mediation 111 Legal

288 Representation 287 111-03 Notary 111 Legal

289 Translation & Interpretation 288 111-04 Representation 111 Legal

289 111-05 Translation & Interpretation 111 Legal


290 rows × 1 columns

290 rows × 4 columns


In [93]: #imputation of missing value
#numeric data>> mean and median>> outlier treatment done>>mean else media
#categorical>> mode In [98]: data1 = {
#impute missing values may be with some constant >>0 'A': [1, 2, None, 4, 5, None, 7, 8, 9, 10],
'B': [None, 11, 12, 13, None, 15, 16, None, 18, 19]
} Out[103… A B

df2 = pd.DataFrame(data1) 0 1.0 NaN


df2
1 2.0 11.0
Out[98]: A B 2 NaN 12.0
0 1.0 NaN 3 4.0 13.0
1 2.0 11.0 4 5.0 NaN
2 NaN 12.0 5 NaN 15.0
3 4.0 13.0 6 7.0 16.0
4 5.0 NaN 7 8.0 NaN
5 NaN 15.0 8 9.0 18.0
6 7.0 16.0 9 10.0 19.0
7 8.0 NaN

8 9.0 18.0 In [105… df2.fillna(0)

9 10.0 19.0 Out[105… A B

0 1.0 0.0
In [101… df2.A.fillna(df2['A'].mean())
1 2.0 11.0
Out[101… 0 1.00 2 0.0 12.0
1 2.00
2 5.75 3 4.0 13.0
3 4.00
4 5.0 0.0
4 5.00
5 5.75 5 0.0 15.0
6 7.00
7 8.00 6 7.0 16.0
8 9.00
7 8.0 0.0
9 10.00
Name: A, dtype: float64 8 9.0 18.0

In [102… df2.A.fillna(df2['A'].median()) 9 10.0 19.0

Out[102… 0 1.0
1 2.0 In [106… df2.fillna("something")
2 6.0
3 4.0
4 5.0
5 6.0
6 7.0
7 8.0
8 9.0
9 10.0
Name: A, dtype: float64

In [103… df2
Out[106… A B Out[110… A B

0 1.0 something 0 1.0 11.0

1 2.0 11.0 1 2.0 11.0

2 something 12.0 2 4.0 12.0

3 4.0 13.0 3 4.0 13.0

4 5.0 something 4 5.0 15.0

5 something 15.0 5 7.0 15.0

6 7.0 16.0 6 7.0 16.0

7 8.0 something 7 8.0 18.0

8 9.0 18.0 8 9.0 18.0

9 10.0 19.0 9 10.0 19.0

In [108… df2.fillna(method = 'ffill') #forward fill>> start seeing from the bottom of dataframe and fillInwith
[113…
the df2.duplicated().sum()
next value observed

Out[108… A B Out[113… 0

0 1.0 NaN
In [117… df.mean()
1 2.0 11.0
/tmp/ipykernel_122/3698961737.py:1: FutureWarning: The default value of numeri
2 2.0 12.0 c_only in DataFrame.mean is deprecated. In a future version, it will default to
False. In addition, specifying 'numeric_only=None' is deprecated. Select only v
3 4.0 13.0
alid columns or specify the value of numeric_only to silence this warning.
4 5.0 13.0 df.mean()

5 5.0 15.0 Out[117… Survived 0.383146


Pclass 2.310112
6 7.0 16.0 Age 29.687475
SibSp 0.522472
7 8.0 16.0 Parch 0.382022
8 9.0 18.0 Fare 32.160299
dtype: float64
9 10.0 19.0
In [118… df.median()

In [110… df2.fillna(method = 'bfill') #backward fill>> see from top and fill with next observed value /tmp/ipykernel_122/530051474.py:1: FutureWarning: The default value of numeri
c_only in DataFrame.median is deprecated. In a future version, it will default
to False. In addition, specifying 'numeric_only=None' is deprecated. Select onl
y valid columns or specify the value of numeric_only to silence this warning.
df.median()
Out[118… Survived 0.0000
Pclass 3.0000
Age 28.0000
SibSp 0.0000
Parch 0.0000
Fare 14.4542
dtype: float64
In [119… df.std() Out[121… Name Survived Pclass Sex Age SibSp Parch Ticket Fare Cabin

/tmp/ipykernel_122/3390915376.py:1: FutureWarning: The default value of numeri Braund,


A/5
c_only in DataFrame.std is deprecated. In a future version, it will default to 0 Mr. Owen 0 3 male 22.0 1 0 7.2500 NaN
21171
False. In addition, specifying 'numeric_only=None' is deprecated. Select only v Harris
alid columns or specify the value of numeric_only to silence this warning.
Heikkinen, STON/
df.std() 1 Miss. 1 3 female 26.0 0 0 O2. 7.9250 NaN
Out[119… Survived 0.486427 Laina 3101282
Pclass 0.835388
Futrelle,
Age 14.533361
Mrs.
SibSp 1.103247 Jacques
Parch 0.806409 2 1 1 female 35.0 1 0 113803 53.1000 C123
Heath
Fare 49.704073 (Lily May
dtype: float64 Peel)

In [120… df.Age.describe() Allen, Mr.


3 William 0 3 male 35.0 0 0 373450 8.0500 NaN
Henry
Out[120… count 713.000000
mean 29.687475 Moran, Mr.
4 0 3 male NaN 0 0 330877 8.4583 NaN
std 14.533361 James
min 0.420000
25% 20.000000 ... ... ... ... ... ... ... ... ... ...
50% 28.000000 Montvila,
75% 38.000000 885 Rev. 0 2 male 27.0 0 0 211536 13.0000 NaN
max 80.000000 Juozas
Name: Age, dtype: float64
Graham,
In [121… df Miss.
886 1 1 female 19.0 0 0 112053 30.0000 B42
Margaret
Edith

Johnston,
Miss.
W./C.
887 Catherine 0 3 female NaN 1 2 23.4500 NaN
6607
Helen
"Carrie"

Behr, Mr.
888 Karl 1 1 male 26.0 0 0 111369 30.0000 C148
Howell

Dooley,
889 0 3 male 32.0 0 0 370376 7.7500 NaN
Mr. Patrick

890 rows × 11 columns

In [122… #Q. What is the average fare paid by people who survive?

In [127… #avg fare whosurvived


df[df.Survived == 1]['Fare'].mean()

Out[127… 48.32828768328446

In [128… #avg fare who didnt survived


df[df.Survived == 0]['Fare'].mean() Out[136… Survived Fare

Out[128… 22.117886885245902 0 0 7.2500

1 1 7.9250
In [130… #groupby
2 1 53.1000
df.groupby('Survived').mean(numeric_only = True)
3 0 8.0500
Out[130… Pclass Age SibSp Parch Fare 4 0 8.4583
Survived ... ... ...
0 2.531876 30.626179 0.553734 0.329690 22.117887 885 0 13.0000
1 1.953079 28.310277 0.472141 0.466276 48.328288 886 1 30.0000

887 0 23.4500
In [131… df.groupby('Survived').min(numeric_only = True)
888 1 30.0000
Out[131… Pclass Age SibSp Parch Fare 889 0 7.7500
Survived
890 rows × 2 columns
0 1 1.00 0 0 0.0

1 1 0.42 0 0 0.0 In [135… import numpy as np


df.groupby(['Survived'])['Fare'].agg([min, 'max', 'mean', 'median', 'count', np

In [132… df.groupby('Survived').sum(numeric_only = True) Out[135… min max mean median count std var

Out[132… Pclass Age SibSp Parch Fare Survived

Survived 0 0.0 263.0000 22.117887 10.5 549 31.388207 985.219509

0 1390 12985.50 304 181 12142.7199 1 0.0 512.3292 48.328288 26.0 341 66.683277 4446.659477

1 666 8181.67 161 159 16479.9461

In [133… df.groupby('Survived').describe()

Out[133… Pclass Age

count mean std min 25% 50% 75% max count mean

Survived

0 549.0 2.531876 0.735805 1.0 2.0 3.0 3.0 3.0 424.0 30.626179

1 341.0 1.953079 0.863047 1.0 1.0 2.0 3.0 3.0 289.0 28.310277

2 rows × 40 columns

In [136… df[['Survived', 'Fare']]


Out[140… Pclass 1 2 3
working of groupby Sex

female 90 70 72

male 45 17 47

In [143… a = df.groupby('Pclass').sum(numeric_only = True)

In [146… a

Out[146… Survived Age SibSp Parch Fare

Pclass

1 135 7073.42 89 77 18106.1292

2 87 5168.83 74 70 3801.8417

3 119 8924.92 302 193 6714.6951

In [145… a.T

Out[145… Pclass 1 2 3
In [138… df.groupby(['Sex', 'Pclass'])['Survived'].sum()
Survived 135.0000 87.0000 119.0000
Out[138… Sex Pclass
female 1 90 Age 7073.4200 5168.8300 8924.9200
2 70 SibSp 89.0000 74.0000 302.0000
3 72
male 1 45 Parch 77.0000 70.0000 193.0000
2 17
Fare 18106.1292 3801.8417 6714.6951
3 47
Name: Survived, dtype: int64

In [139… df.groupby(['Sex', 'Pclass'])['Survived'].sum().to_frame() In [149… a.transpose()

Out[139… Survived Out[149… Pclass 1 2 3

Sex Pclass Survived 135.0000 87.0000 119.0000

female 1 90 Age 7073.4200 5168.8300 8924.9200

2 70 SibSp 89.0000 74.0000 302.0000

3 72 Parch 77.0000 70.0000 193.0000

male 1 45 Fare 18106.1292 3801.8417 6714.6951

2 17
In [150… df.head().T
3 47

In [140… df.groupby(['Sex', 'Pclass'])['Survived'].sum().unstack()


Out[150… Name Survived Pclass Sex Age SibSp Parch Ticket Fare Cabin In [1]: import pandas as pd
import numpy as np
Braund,
A/5
0 Mr. Owen 0 3 male 22.0 1 0 7.2500 NaN
21171 In [2]: df = pd.read_csv("https://raw.githubusercontent.com/datasciencedojo/datasets/master/ti
Harris

Heikkinen, STON/ In [6]: df1 = df[["Name", "Sex", "Age"]][0:5]


1 Miss. 1 3 female 26.0 0 0 O2. 7.9250 NaN
Laina 3101282
In [7]: df1
Futrelle,
Mrs. Out[7]: Name Sex Age
Jacques
2 1 1 female 35.0 1 0 113803 53.1000 C123
Heath 0 Braund, Mr. Owen Harris male 22.0
(Lily May
Peel) 1 Cumings, Mrs. John Bradley (Florence Briggs Th... female 38.0

Allen, Mr. 2 Heikkinen, Miss. Laina female 26.0


3 William 0 3 male 35.0 0 0 373450 8.0500 NaN
Henry 3 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35.0

Moran, Mr. 4 Allen, Mr. William Henry male 35.0


4 0 3 male NaN 0 0 330877 8.4583 NaN
James

In [8]: df2 = df[["Name", "Sex", "Age"]][5:10]


In [ ]:
In [9]: df2

Out[9]: Name Sex Age

5 Moran, Mr. James male NaN

6 McCarthy, Mr. Timothy J male 54.0

7 Palsson, Master. Gosta Leonard male 2.0

8 Johnson, Mrs. Oscar W (Elisabeth Vilhelmina Berg) female 27.0

9 Nasser, Mrs. Nicholas (Adele Achem) female 14.0

In [10]: "PW" + "Skill"

Out[10]: 'PWSkill'

In [11]: df1

Out[11]: Name Sex Age

0 Braund, Mr. Owen Harris male 22.0

1 Cumings, Mrs. John Bradley (Florence Briggs Th... female 38.0

2 Heikkinen, Miss. Laina female 26.0

3 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35.0

4 Allen, Mr. William Henry male 35.0


In [12]: df2 Out[14]: Name Sex Age Name Sex Age

Out[12]: Name Sex Age 0 Braund, Mr. Owen Harris male 22.0 NaN NaN NaN

5 Moran, Mr. James male NaN Cumings, Mrs. John


1 Bradley (Florence Briggs female 38.0 NaN NaN NaN
6 McCarthy, Mr. Timothy J male 54.0 Th...

7 Palsson, Master. Gosta Leonard male 2.0 2 Heikkinen, Miss. Laina female 26.0 NaN NaN NaN

8 Johnson, Mrs. Oscar W (Elisabeth Vilhelmina Berg) female 27.0 Futrelle, Mrs. Jacques
3 female 35.0 NaN NaN NaN
Heath (Lily May Peel)
9 Nasser, Mrs. Nicholas (Adele Achem) female 14.0
4 Allen, Mr. William Henry male 35.0 NaN NaN NaN

5 NaN NaN NaN Moran, Mr. James male NaN


In [13]: pd.concat([df1, df2], axis =0) #Concatenate pandas objects along a particular axis.
6 NaN NaN NaN McCarthy, Mr. Timothy J male 54.0
Out[13]: Name Sex Age
Palsson, Master. Gosta
0 Braund, Mr. Owen Harris male 22.0 7 NaN NaN NaN male 2.0
Leonard

1 Cumings, Mrs. John Bradley (Florence Briggs Th... female 38.0 Johnson, Mrs. Oscar W
8 NaN NaN NaN (Elisabeth Vilhelmina female 27.0
2 Heikkinen, Miss. Laina female 26.0 Berg)
3 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35.0 Nasser, Mrs. Nicholas
9 NaN NaN NaN female 14.0
(Adele Achem)
4 Allen, Mr. William Henry male 35.0

5 Moran, Mr. James male NaN


In [18]: df2.reset_index(drop = True, inplace = True)
6 McCarthy, Mr. Timothy J male 54.0 df2
7 Palsson, Master. Gosta Leonard male 2.0
Out[18]: Name Sex Age
8 Johnson, Mrs. Oscar W (Elisabeth Vilhelmina Berg) female 27.0
0 Moran, Mr. James male NaN
9 Nasser, Mrs. Nicholas (Adele Achem) female 14.0
1 McCarthy, Mr. Timothy J male 54.0

2 Palsson, Master. Gosta Leonard male 2.0


In [14]: pd.concat([df1, df2], axis =1)
3 Johnson, Mrs. Oscar W (Elisabeth Vilhelmina Berg) female 27.0

4 Nasser, Mrs. Nicholas (Adele Achem) female 14.0

In [16]: df1

Out[16]: Name Sex Age

0 Braund, Mr. Owen Harris male 22.0

1 Cumings, Mrs. John Bradley (Florence Briggs Th... female 38.0

2 Heikkinen, Miss. Laina female 26.0

3 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35.0

4 Allen, Mr. William Henry male 35.0


In [19]: pd.concat([df1, df2], axis =1) Out[23]: key1 key4 key5

Out[19]: Name Sex Age Name Sex Age 0 1 56 3

0 Braund, Mr. Owen Harris male 22.0 Moran, Mr. James male NaN 1 2 5 56

Cumings, Mrs. John 2 45 6 5


1 Bradley (Florence Briggs female 38.0 McCarthy, Mr. Timothy J male 54.0
Th... 3 6 7 6

Palsson, Master. Gosta 4 67 8 6


2 Heikkinen, Miss. Laina female 26.0 male 2.0
Leonard

Johnson, Mrs. Oscar W In [24]: df1


Futrelle, Mrs. Jacques
3 female 35.0 (Elisabeth Vilhelmina female 27.0
Heath (Lily May Peel)
Berg)
Out[24]: key1 key2 key3
Nasser, Mrs. Nicholas
4 Allen, Mr. William Henry male 35.0 female 14.0 0 1 4 3
(Adele Achem)
1 2 5 4

In [ ]: #merge 2 4 6 5

3 5 7 6
In [20]: df1 = pd.DataFrame({'key1':[1,2,4,5,6],
'key2':[4,5,6,7,8], 4 6 8 6
'key3':[3,4,5,6,6]
})
In [25]: df2
In [21]: df1
Out[25]: key1 key4 key5
Out[21]: key1 key2 key3
0 1 56 3
0 1 4 3 1 2 5 56
1 2 5 4 2 45 6 5
2 4 6 5 3 6 7 6
3 5 7 6 4 67 8 6
4 6 8 6

In [26]: pd.merge(df1, df2, how = 'inner')


In [22]: df2 = pd.DataFrame({'key1':[1,2,45,6,67],
'key4':[56,5,6,7,8], Out[26]: key1 key2 key3 key4 key5
'key5':[3,56,5,6,6]
0 1 4 3 56 3
}
) 1 2 5 4 5 56

2 6 8 6 7 6
In [23]: df2

In [27]: pd.merge(df1, df2, how = 'left')


Out[27]: key1 key2 key3 key4 key5 In [31]: df1

0 1 4 3 56.0 3.0 Out[31]: key1 key2 key3

1 2 5 4 5.0 56.0 0 1 4 3

2 4 6 5 NaN NaN 1 2 5 4

3 5 7 6 NaN NaN 2 4 6 5

4 6 8 6 7.0 6.0 3 5 7 6

4 6 8 6
In [28]: df2

Out[28]: key1 key4 key5 In [32]: df1

0 1 56 3 Out[32]: key1 key2 key3

1 2 5 56 0 1 4 3

2 45 6 5 1 2 5 4

3 6 7 6 2 4 6 5

4 67 8 6 3 5 7 6

4 6 8 6
In [29]: pd.merge(df1, df2, how = 'right')

Out[29]: key1 key2 key3 key4 key5 In [33]: df2

0 1 4.0 3.0 56 3 Out[33]: key1 key4 key5

1 2 5.0 4.0 5 56 0 1 56 3

2 45 NaN NaN 6 5 1 2 5 56

3 6 8.0 6.0 7 6 2 45 6 5

4 67 NaN NaN 8 6 3 6 7 6

4 67 8 6
In [30]: pd.merge(df1, df2, how = 'outer') #all the keys from both the datframe

Out[30]: key1 key2 key3 key4 key5 In [34]: pd.merge(df1, df2, how = 'cross')

0 1 4.0 3.0 56.0 3.0

1 2 5.0 4.0 5.0 56.0

2 4 6.0 5.0 NaN NaN

3 5 7.0 6.0 NaN NaN

4 6 8.0 6.0 7.0 6.0

5 45 NaN NaN 6.0 5.0

6 67 NaN NaN 8.0 6.0


Out[34]: key1_x key2 key3 key1_y key4 key5 Out[36]: key1_x key2 key3 key1_y key4 key5

0 1 4 3 1 56 3 0 1 4 3 NaN NaN NaN

1 1 4 3 2 5 56 1 2 5 4 2.0 5.0 56.0

2 1 4 3 45 6 5 2 4 6 5 45.0 6.0 5.0

3 1 4 3 6 7 6 3 5 7 6 6.0 7.0 6.0

4 1 4 3 67 8 6 4 6 8 6 67.0 8.0 6.0

5 2 5 4 1 56 3

6 2 5 4 2 5 56 In [37]: #join
df1 = pd.DataFrame({'key1':[1,2,4,5,6],
7 2 5 4 45 6 5 'key2':[4,5,6,7,8],
'key3':[3,4,5,6,6]},
8 2 5 4 6 7 6
index = ['a', 'b', 'c', 'd', 'e']
9 2 5 4 67 8 6 )

10 4 6 5 1 56 3
In [38]: df2 = pd.DataFrame({'key6':[1,2,45,6,67],
11 4 6 5 2 5 56 'key4':[56,5,6,7,8],
'key5':[3,56,5,6,6]
12 4 6 5 45 6 5 },
index = ['a', 'b', 'h', 'i', 'j']
13 4 6 5 6 7 6
)
14 4 6 5 67 8 6
In [39]: df1
15 5 7 6 1 56 3

16 5 7 6 2 5 56 Out[39]: key1 key2 key3

17 5 7 6 45 6 5 a 1 4 3

18 5 7 6 6 7 6 b 2 5 4

19 5 7 6 67 8 6 c 4 6 5

20 6 8 6 1 56 3 d 5 7 6

21 6 8 6 2 5 56 e 6 8 6

22 6 8 6 45 6 5
In [40]: df2
23 6 8 6 6 7 6

24 6 8 6 67 8 6 Out[40]: key6 key4 key5

a 1 56 3
In [36]: pd.merge(df1, df2, how = "left", left_on = "key2", right_on = "key4") b 2 5 56

h 45 6 5

i 6 7 6

j 67 8 6

In [41]: df1.join(df2, how = "inner") #Join columns of another DataFrame.


Out[41]: key1 key2 key3 key6 key4 key5 Out[45]: key1 key2 key3 key6 key4 key5

a 1 4 3 1 56 3 0 1 4 3 1 56 3

b 2 5 4 2 5 56 1 1 4 3 2 5 56

2 1 4 3 45 6 5
In [42]: df1.join(df2, how = "left") 3 1 4 3 6 7 6

Out[42]: key1 key2 key3 key6 key4 key5 4 1 4 3 67 8 6

a 1 4 3 1.0 56.0 3.0 5 2 5 4 1 56 3

b 2 5 4 2.0 5.0 56.0 6 2 5 4 2 5 56

c 4 6 5 NaN NaN NaN 7 2 5 4 45 6 5

d 5 7 6 NaN NaN NaN 8 2 5 4 6 7 6

e 6 8 6 NaN NaN NaN 9 2 5 4 67 8 6

10 4 6 5 1 56 3
In [43]: df1.join(df2, how = "right") 11 4 6 5 2 5 56

Out[43]: key1 key2 key3 key6 key4 key5 12 4 6 5 45 6 5

a 1.0 4.0 3.0 1 56 3 13 4 6 5 6 7 6

b 2.0 5.0 4.0 2 5 56 14 4 6 5 67 8 6

h NaN NaN NaN 45 6 5 15 5 7 6 1 56 3

i NaN NaN NaN 6 7 6 16 5 7 6 2 5 56

j NaN NaN NaN 67 8 6 17 5 7 6 45 6 5

18 5 7 6 6 7 6

In [44]: df1.join(df2, how = "outer") 19 5 7 6 67 8 6

Out[44]: key1 key2 key3 key6 key4 key5 20 6 8 6 1 56 3

a 1.0 4.0 3.0 1.0 56.0 3.0 21 6 8 6 2 5 56

b 2.0 5.0 4.0 2.0 5.0 56.0 22 6 8 6 45 6 5

c 4.0 6.0 5.0 NaN NaN NaN 23 6 8 6 6 7 6

d 5.0 7.0 6.0 NaN NaN NaN 24 6 8 6 67 8 6

e 6.0 8.0 6.0 NaN NaN NaN


In [46]: df
h NaN NaN NaN 45.0 6.0 5.0

i NaN NaN NaN 6.0 7.0 6.0

j NaN NaN NaN 67.0 8.0 6.0

In [45]: df1.join(df2, how = "cross")


Out[46]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket Out[50]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket

Braund, Braund,
A/5 A/5
0 1 0 3 Mr. Owen male 22.0 1 0 0 1 0 3 Mr. Owen male 22.0 1 0
21171 21171
Harris Harris

Cumings, Cumings,
Mrs. John Mrs. John
Bradley PC Bradley PC
1 2 1 1 female 38.0 1 0 1 2 1 1 female 38.0 1 0
(Florence 17599 (Florence 17599
Briggs Briggs
Th... Th...

Heikkinen, STON/ Heikkinen, STON/


2 3 1 3 Miss. female 26.0 0 0 O2. 2 3 1 3 Miss. female 26.0 0 0 O2.
Laina 3101282 Laina 3101282

Futrelle, Futrelle,
Mrs. Mrs.
Jacques Jacques
3 4 1 1 female 35.0 1 0 113803 3 4 1 1 female 35.0 1 0 113803
Heath Heath
(Lily May (Lily May
Peel) Peel)

Allen, Mr. Allen, Mr.


4 5 0 3 William male 35.0 0 0 373450 4 5 0 3 William male 35.0 0 0 373450
Henry Henry

... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...

Montvila, Montvila,
886 887 0 2 Rev. male 27.0 0 0 211536 886 887 0 2 Rev. male 27.0 0 0 211536
Juozas Juozas

Graham, Graham,
Miss. Miss.
887 888 1 1 female 19.0 0 0 112053 887 888 1 1 female 19.0 0 0 112053
Margaret Margaret
Edith Edith

Johnston, Johnston,
Miss. Miss.
W./C. W./C.
888 889 0 3 Catherine female NaN 1 2 888 889 0 3 Catherine female NaN 1 2
6607 6607
Helen Helen
"Carrie" "Carrie"

Behr, Mr. Behr, Mr.


889 890 1 1 Karl male 26.0 0 0 111369 889 890 1 1 Karl male 26.0 0 0 111369
Howell Howell

Dooley, Dooley,
890 891 0 3 male 32.0 0 0 370376 890 891 0 3 male 32.0 0 0 370376
Mr. Patrick Mr. Patrick

891 rows × 12 columns 891 rows × 13 columns

In [49]: df['Fare_inr'] = df['Fare'].apply(lambda x: x*90) In [51]: df['Fare_inr']

In [50]: df
Out[51]: 0 652.500 Out[62]: 0 652.500
1 6415.497 1 6415.497
2 713.250 2 713.250
3 4779.000 3 4779.000
4 724.500 4 724.500
... ...
886 1170.000 886 1170.000
887 2700.000 887 2700.000
888 2110.500 888 2110.500
889 2700.000 889 2700.000
890 697.500 890 697.500
Name: Fare_inr, Length: 891, dtype: float64 Name: Fare_1, Length: 891, dtype: float64

In [52]: len("Ram") In [63]: def create_flag(x):


if x < 10:
Out[52]: 3 return "cheap"
elif x>=10 and x<20:
In [55]: df['Name_len'] = df['Name'].apply(len) return "medium"
else:
return "high"
In [56]: df['Name_len']

Out[56]: 0 23
1 51 In [66]: df['flag_fare'] = df['Fare'].apply(create_flag)
2 22
3 44 In [67]: df
4 24
..
886 21
887 28
888 40
889 21
890 19
Name: Name_len, Length: 891, dtype: int64

In [59]: def convert(x):


return x*90

In [61]: df['Fare_1'] = df['Fare'].apply(convert)

In [62]: df['Fare_1']
Out[67]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket In [95]: df1

Braund, Out[95]: a b c
A/5
0 1 0 3 Mr. Owen male 22.0 1 0
21171 0 1 5 pw
Harris

Cumings, 1 2 5 skills
Mrs. John
Bradley PC 2 3 6 aj
1 2 1 1 female 38.0 1 0
(Florence 17599
Briggs 3 4 7 cj
Th...

Heikkinen, STON/ In [96]: df1.set_index('c', inplace = True)


2 3 1 3 Miss. female 26.0 0 0 O2.
Laina 3101282
In [97]: df1
Futrelle,
Mrs. Out[97]: a b
Jacques
3 4 1 1 female 35.0 1 0 113803
Heath c
(Lily May
Peel) pw 1 5

Allen, Mr. skills 2 5


4 5 0 3 William male 35.0 0 0 373450
Henry aj 3 6

... ... ... ... ... ... ... ... ... ... cj 4 7

Montvila,
886 887 0 2 Rev. male 27.0 0 0 211536 In [98]: df1.reset_index(drop = True, inplace=True)
Juozas

Graham, In [99]: df1


Miss.
887 888 1 1 female 19.0 0 0 112053
Margaret Out[99]: a b
Edith
0 1 5
Johnston,
Miss. 1 2 5
W./C.
888 889 0 3 Catherine female NaN 1 2
6607
Helen 2 3 6
"Carrie"
3 4 7
Behr, Mr.
889 890 1 1 Karl male 26.0 0 0 111369
Howell
In [100… df1.reindex([1, 2, 3, 0]) #Conform Series/DataFrame to new index with optional filling
Dooley,
890 891 0 3 male 32.0 0 0 370376 Out[100… a b
Mr. Patrick

1 2 5
891 rows × 16 columns
2 3 6

In [94]: data = {"a": [1, 2, 3, 4], 3 4 7


"b": [5, 5, 6, 7], 0 1 5
"c": ["pw", "skills", "aj", "cj"]}
df1 = pd.DataFrame(data)
In [101… df1
Out[101… a b In [107… df1.apply(func_sum, axis =0)

0 1 5 Out[107… a 10
b 23
1 2 5 dtype: int64
2 3 6
In [108… df1
3 4 7
Out[108… a b

In [102… for i in df1.iterrows(): #row wise 0 1 5


print(i, "---------------------") 1 2 5
(0, a 1 2 3 6
b 5
Name: 0, dtype: int64) --------------------- 3 4 7
(1, a 2
b 5
Name: 1, dtype: int64) --------------------- In [109… df1.apply(func_sum, axis =1)
(2, a 3
b 6 Out[109… 0 6
Name: 2, dtype: int64) --------------------- 1 7
(3, a 4 2 9
b 7 3 11
Name: 3, dtype: int64) --------------------- dtype: int64

In [103… for i in df1.items():#column wise In [111… df1.applymap(lambda x: x**2)


print(i)
Out[111… a b
('a', 0 1
1 2 0 1 25
2 3
3 4 1 4 25
Name: a, dtype: int64) 2 9 36
('b', 0 5
1 5 3 16 49
2 6
3 7
Name: b, dtype: int64) In [112… df1

In [104… df1 Out[112… a b

Out[104… a b 0 1 5

0 1 5 1 2 5

1 2 5 2 3 6

2 3 6 3 4 7

3 4 7
In [113… df1

In [105… def func_sum(x):


return x.sum()
Out[113… a b Out[120… PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket

0 1 5 Braund,
A/5
0 1 0 3 Mr. Owen male 22.0 1 0
1 2 5 21171
Harris
2 3 6 Cumings,
Mrs. John
3 4 7 Bradley PC
1 2 1 1 female 38.0 1 0
(Florence 17599
Briggs
In [117… data = {"a": [100, 200, 13, 4], Th...
"b": [5, 5, 6, 7],
Heikkinen, STON/
"c": ["pw", "skills", "aj", "cj"]}
2 3 1 3 Miss. female 26.0 0 0 O2.
df2 = pd.DataFrame(data) Laina 3101282

In [118… df2 Futrelle,


Mrs.
Jacques
Out[118… a b c 3 4 1 1 female 35.0 1 0 113803
Heath
(Lily May
0 100 5 pw
Peel)
1 200 5 skills
Allen, Mr.
2 13 6 aj 4 5 0 3 William male 35.0 0 0 373450
Henry
3 4 7 cj
... ... ... ... ... ... ... ... ... ...

Montvila,
In [119… df2.sort_values(by = 'a') 886 887 0 2 Rev. male 27.0 0 0 211536
Juozas
Out[119… a b c
Graham,
3 4 7 cj Miss.
887 888 1 1 female 19.0 0 0 112053
Margaret
2 13 6 aj Edith

0 100 5 pw Johnston,
Miss.
1 200 5 skills W./C.
888 889 0 3 Catherine female NaN 1 2
6607
Helen
"Carrie"
In [120… df
Behr, Mr.
889 890 1 1 Karl male 26.0 0 0 111369
Howell

Dooley,
890 891 0 3 male 32.0 0 0 370376
Mr. Patrick

891 rows × 16 columns

In [ ]:
In [2]: import pandas as pd Out[4]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket
import numpy as np
Braund,
A/5
0 1 0 3 Mr. Owen male 22.0 1 0
In [3]: df = pd.read_csv("https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv" 21171
Harris

In [4]: df Cumings,
Mrs. John
Bradley PC
1 2 1 1 female 38.0 1 0
(Florence 17599
Briggs
Th...

Heikkinen, STON/
2 3 1 3 Miss. female 26.0 0 0 O2.
Laina 3101282

Futrelle,
Mrs.
Jacques
3 4 1 1 female 35.0 1 0 113803
Heath
(Lily May
Peel)

Allen, Mr.
4 5 0 3 William male 35.0 0 0 373450
Henry

... ... ... ... ... ... ... ... ... ...

Montvila,
886 887 0 2 Rev. male 27.0 0 0 211536
Juozas

Graham,
Miss.
887 888 1 1 female 19.0 0 0 112053
Margaret
Edith

Johnston,
Miss.
W./C.
888 889 0 3 Catherine female NaN 1 2
6607
Helen
"Carrie"

Behr, Mr.
889 890 1 1 Karl male 26.0 0 0 111369
Howell

Dooley,
890 891 0 3 male 32.0 0 0 370376
Mr. Patrick

891 rows × 12 columns

In [5]: df1 = pd.DataFrame({"description":["PW Skills is the one-stop destination for your ups

In [6]: df1
Out[6]: description Out[10]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket

0 PW Skills is the one-stop destination for your... Braund,


A/5
0 1 0 3 Mr. Owen male 22.0 1 0
21171
Harris
In [7]: pd.set_option('display.max_colwidth', 1000)
Cumings,
Mrs. John
In [8]: df1 Bradley PC
1 2 1 1 female 38.0 1 0
(Florence 17599
Out[8]: description Briggs
Thayer)
PW Skills is the one-stop destination for your upskilling journey. Brace yourself to find
the best job-ready courses and high-end technologies available in the sector. And if Heikkinen, STON/
0 2 3 1 3 Miss. female 26.0 0 0 O2.
that weren't good enough, get the highest quality course content at the most
affordable prices!What are we waiting for ? Let's push Start! Laina 3101282

Futrelle,
Mrs.
In [10]: df Jacques
3 4 1 1 female 35.0 1 0 113803
Heath
(Lily May
Peel)

Allen, Mr.
4 5 0 3 William male 35.0 0 0 373450
Henry

... ... ... ... ... ... ... ... ... ...

Montvila,
886 887 0 2 Rev. male 27.0 0 0 211536
Juozas

Graham,
Miss.
887 888 1 1 female 19.0 0 0 112053
Margaret
Edith

Johnston,
Miss.
W./C.
888 889 0 3 Catherine female NaN 1 2
6607
Helen
"Carrie"

Behr, Mr.
889 890 1 1 Karl male 26.0 0 0 111369
Howell

Dooley,
890 891 0 3 male 32.0 0 0 370376
Mr. Patrick

891 rows × 12 columns

In [14]: pd.set_option('display.max_rows', 100)


pd.set_option('display.max_columns', 100)

In [16]: df[:500]
Out[16]: PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket Out[19]: description char_len

Braund, PW Skills is the one-stop destination for your upskilling journey. Brace
A/5
0 1 0 3 Mr. Owen male 22.0 1 0 yourself to find the best job-ready courses and high-end technologies
21171
Harris 0 available in the sector. And if that weren't good enough, get the highest 313
quality course content at the most affordable prices!What are we waiting
Cumings, for ? Let's push Start!
Mrs. John
Bradley PC
1 2 1 1 female 38.0 1 0
(Florence 17599
In [20]: a = "I am Ajay"
Briggs
Thayer) len(a)

Heikkinen, STON/ Out[20]: 9


2 3 1 3 Miss. female 26.0 0 0 O2.
Laina 3101282
In [22]: len(a.split())
Futrelle,
Mrs. Out[22]: 3
Jacques
3 4 1 1 female 35.0 1 0 113803
Heath
(Lily May In [23]: df1['word_count'] = df1['description'].apply(lambda x: len(x.split()))
Peel)
In [24]: df1
Allen, Mr.
4 5 0 3 William male 35.0 0 0 373450
Out[24]: description char_len word_count
Henry

... ... ... ... ... ... ... ... ... ... PW Skills is the one-stop destination for your upskilling
journey. Brace yourself to find the best job-ready courses
Yousseff, and high-end technologies available in the sector. And if
0 313 50
495 496 0 3 Mr. male NaN 0 0 2627 that weren't good enough, get the highest quality course
Gerious content at the most affordable prices!What are we waiting
for ? Let's push Start!
Eustis,
Miss.
496 497 1 1 female 54.0 1 0 36947
Elizabeth In [30]: data = {'text':['Hello data science', 'I love ML', 'I read ml books']}
Mussey a = pd.DataFrame(data)
Shellard,
Mr. C.A In [31]: a
497 498 0 3 male NaN 0 0
Frederick 6212
William Out[31]: text
Allison, 0 Hello data science
Mrs.
Hudson J 1 I love ML
498 499 0 1 female 25.0 1 2 113781
C (Bessie
Waldo 2 I read ml books
Daniels)

Svensson,
499 500 0 3 male 24.0 0 0 350035 In [33]: a['text_lower'] = a['text'].str.lower()
Mr. Olof

500 rows × 12 columns In [34]: a

In [18]: df1["char_len"] = df1['description'].apply(len)

In [19]: df1
Out[34]: text text_lower Out[46]: a b mul_a

0 Hello data science hello data science 0 1 4 5

1 I love ML i love ml 1 2 5 10

2 I read ml books i read ml books 2 4 6 20

3 5 7 25
In [35]: a['text_upper'] = a['text'].str.upper() 4 6 8 30

In [36]: a
In [47]: df1.a.mean()
Out[36]: text text_lower text_upper
Out[47]: 3.6
0 Hello data science hello data science HELLO DATA SCIENCE

1 I love ML i love ml I LOVE ML In [48]: df1.a.median()

2 I read ml books i read ml books I READ ML BOOKS Out[48]: 4.0

In [49]: df1.a.mode()
In [42]: a['text'][0].startswith('H')

Out[49]: 0 1
Out[42]: True
1 2
2 4
In [43]: df1 = pd.DataFrame({'a':[1,2,4,5,6], 3 5
'b':[4,5,6,7,8], 4 6
}) Name: a, dtype: int64

In [44]: df1 In [50]: df1.a.min()

Out[44]: a b Out[50]: 1

0 1 4
In [51]: df1.a.max()
1 2 5
Out[51]: 6
2 4 6

3 5 7 In [52]: df1.a.sum()

4 6 8 Out[52]: 18

In [53]: df1.a.std()
In [45]: df1['mul_a'] = df1['a'] *5
Out[53]: 2.073644135332772
In [46]: df1
In [54]: df1.a.var()

Out[54]: 4.3

In [55]: df1.a.describe()
Out[55]: count 5.000000 Out[59]: a
mean 3.600000
std 2.073644 0 1.0
min 1.000000 1 2.0
25% 2.000000
50% 4.000000 2 3.0
75% 5.000000
max 6.000000 3 4.0
Name: a, dtype: float64 4 5.0

In [56]: df2 = pd.DataFrame({"a": [1, 2, 3, 4, 5, 6, 7, 8, 9]}) 5 6.0

6 7.0
In [57]: df2
7 8.0
Out[57]: a
8 9.0
0 1

1 2 In [60]: df2.rolling(window = 2).mean()


2 3
Out[60]: a
3 4
0 NaN
4 5
1 1.5
5 6
2 2.5
6 7
3 3.5
7 8
4 4.5
8 9
5 5.5

6 6.5
In [58]: df2.mean()
7 7.5
Out[58]: a 5.0
dtype: float64 8 8.5

In [59]: df2.rolling(window = 1).mean() #Provide rolling window calculations.


In [62]: df3 = df2.rolling(window = 3).mean()

In [64]: df3.dropna(inplace=True)

In [65]: df3
Out[65]: a In [71]: df2.rolling(window =2).min()

2 2.0 Out[71]: a

3 3.0 0 NaN

4 4.0 1 1.0

5 5.0 2 2.0

6 6.0 3 3.0

7 7.0 4 4.0

8 8.0 5 5.0

6 6.0
In [67]: df3['a_int'] = df3['a'].astype(int) 7 7.0

In [68]: df3 8 8.0

Out[68]: a a_int
In [72]: df2.rolling(window =2).max()
2 2.0 2
Out[72]: a
3 3.0 3
0 NaN
4 4.0 4
1 2.0
5 5.0 5
2 3.0
6 6.0 6
3 4.0
7 7.0 7
4 5.0
8 8.0 8
5 6.0

In [70]: df2.rolling(window =2).sum() 6 7.0

7 8.0
Out[70]: a
8 9.0
0 NaN

1 3.0
In [73]: df2
2 5.0

3 7.0

4 9.0

5 11.0

6 13.0

7 15.0

8 17.0
Out[73]: a In [81]: df2['a'].cumsum()

0 1 Out[81]: 0 1
1 3
1 2 2 6
2 3 3 10
4 15
3 4 5 21
6 28
4 5
7 36
5 6 8 45
Name: a, dtype: int64
6 7
In [82]: df2
7 8

8 9 Out[82]: a Group

0 1 A

In [76]: df2['Group'] = np.random.choice(['A', 'B'], size = 9) 1 2 A

2 3 A
In [77]: df2
3 4 A
Out[77]: a Group
4 5 B
0 1 A
5 6 A
1 2 A
6 7 A
2 3 A
7 8 B
3 4 A
8 9 A
4 5 B

5 6 A
In [83]: df = pd.DataFrame({"date": ['2024-03-08', '2024-03-09', '2024-03-10']})
6 7 A
In [85]: df.dtypes
7 8 B

8 9 A Out[85]: date object


dtype: object

In [79]: df2.groupby('Group')['a'].rolling(window = 2).sum() In [88]: df['update_date'] = pd.to_datetime(df['date'])

Out[79]: Group In [89]: df


A 0 NaN
1 3.0 Out[89]: date update_date
2 5.0
0 2024-03-08 2024-03-08
3 7.0
5 10.0 1 2024-03-09 2024-03-09
6 13.0
8 16.0 2 2024-03-10 2024-03-10
B 4 NaN
7 13.0
Name: a, dtype: float64 In [90]: df.dtypes
Out[90]: date object Out[100… DatetimeIndex(['2024-03-10 00:00:00', '2024-03-10 01:00:00',
update_date datetime64[ns] '2024-03-10 02:00:00', '2024-03-10 03:00:00',
dtype: object '2024-03-10 04:00:00', '2024-03-10 05:00:00',
'2024-03-10 06:00:00', '2024-03-10 07:00:00',
In [92]: df['year'] = df['update_date'].dt.year '2024-03-10 08:00:00', '2024-03-10 09:00:00',
...
In [93]: df '2025-03-09 15:00:00', '2025-03-09 16:00:00',
'2025-03-09 17:00:00', '2025-03-09 18:00:00',
Out[93]: date update_date year '2025-03-09 19:00:00', '2025-03-09 20:00:00',
'2025-03-09 21:00:00', '2025-03-09 22:00:00',
0 2024-03-08 2024-03-08 2024 '2025-03-09 23:00:00', '2025-03-10 00:00:00'],
dtype='datetime64[ns]', length=8761, freq='H')
1 2024-03-09 2024-03-09 2024

2 2024-03-10 2024-03-10 2024 In [102… start = pd.Timestamp.now()

In [94]: df['month'] = df['update_date'].dt.month for i in range(1000):


pass

In [95]: df end = pd.Timestamp.now()

Out[95]: date update_date year month


print("time taken", end-start)
0 2024-03-08 2024-03-08 2024 3 time taken 0 days 00:00:00.000144
1 2024-03-09 2024-03-09 2024 3
In [103… start = pd.Timestamp.now() - pd.DateOffset(weeks = 1)
2 2024-03-10 2024-03-10 2024 3 start

Out[103… Timestamp('2024-03-21 19:51:21.961611')


In [96]: df['day'] = df['update_date'].dt.day
In [104… end = pd.Timestamp.now()
In [97]: df
In [105… end-start
Out[97]: date update_date year month day
Out[105… Timedelta('7 days 00:00:40.228907')
0 2024-03-08 2024-03-08 2024 3 8

1 2024-03-09 2024-03-09 2024 3 9 In [107… from datetime import datetime


2 2024-03-10 2024-03-10 2024 3 10
date = "2024-03-29"
date = datetime.strptime(date, "%Y-%m-%d")
In [99]: pd.date_range(start = '2024-03-10', end ='2025-03-10', freq = 'D') #generates daily data
In [108… date
Out[99]: DatetimeIndex(['2024-03-10', '2024-03-11', '2024-03-12', '2024-03-13',
'2024-03-14', '2024-03-15', '2024-03-16', '2024-03-17', Out[108… datetime.datetime(2024, 3, 29, 0, 0)
'2024-03-18', '2024-03-19',
... In [109… print(date)
'2025-03-01', '2025-03-02', '2025-03-03', '2025-03-04',
'2025-03-05', '2025-03-06', '2025-03-07', '2025-03-08', 2024-03-29 00:00:00
'2025-03-09', '2025-03-10'],
dtype='datetime64[ns]', length=366, freq='D') In [110… time = pd.Timedelta(days =1, hours=5, minutes =40)

In [100… pd.date_range(start = '2024-03-10', end ='2025-03-10', freq = 'H') In [111… time


Out[111… Timedelta('1 days 05:40:00') Out[121… Date
2023-03-31 98.558696
In [112… dt = pd.to_datetime('2024-03-29') 2023-04-30 106.348422
2023-05-31 116.745682
2023-06-30 123.228096
In [113… dt
2023-07-31 123.553499
2023-08-31 131.149131
Out[113… Timestamp('2024-03-29 00:00:00')
2023-09-30 135.196502
2023-10-31 135.354091
In [114… dt+time 2023-11-30 134.868570
2023-12-31 136.907500
Out[114… Timestamp('2024-03-30 05:40:00') 2024-01-31 145.425714
2024-02-29 144.067999
In [116… #pip install yfinance Freq: M, Name: Close, dtype: float64

In [122… data['Close'].resample('D').mean()
In [115… import yfinance as yf
Out[122… Date
In [118… data = yf.download('GOOG', start = '2023-03-01', end = '2024-03-01') 2023-03-01 90.510002
2023-03-02 92.309998
[*********************100%%**********************] 1 of 1 completed 2023-03-03 94.019997
2023-03-04 NaN
In [119… data 2023-03-05 NaN
...
Out[119… Open High Low Close Adj Close Volume 2024-02-25 NaN
Date 2024-02-26 138.750000
2024-02-27 140.100006
2023-03-01 90.160004 91.199997 89.849998 90.510002 90.510002 26323900 2024-02-28 137.429993
2024-02-29 139.779999
2023-03-02 89.860001 92.480003 89.769997 92.309998 92.309998 23328600 Freq: D, Name: Close, Length: 366, dtype: float64
2023-03-03 92.739998 94.110001 92.660004 94.019997 94.019997 30242500
In [124… #plotting function in pandas
2023-03-06 94.360001 96.300003 94.300003 95.580002 95.580002 28288200
d = pd.Series([1, 2, 3, 8, 9, 6])
2023-03-07 95.419998 96.089996 93.844002 94.169998 94.169998 24101500

... ... ... ... ... ... ... In [125… d.plot()

2024-02-23 144.970001 145.955002 144.789993 145.289993 145.289993 14519400 Out[125… <AxesSubplot: >
2024-02-26 143.449997 143.839996 138.740005 138.750000 138.750000 33513000

2024-02-27 139.410004 140.490005 138.500000 140.100006 140.100006 22364000

2024-02-28 139.100006 139.279999 136.639999 137.429993 137.429993 30628700

2024-02-29 138.350006 139.949997 137.570007 139.779999 139.779999 35485000

252 rows × 6 columns

In [121… data['Close'].resample('M').mean()
In [126… data = {"A": [1, 2, 3], "B": [4, 5, 6]} In [128… df['A'].plot(kind = 'line')
df = pd.DataFrame(data)
df Out[128… <AxesSubplot: >

Out[126… A B

0 1 4

1 2 5

2 3 6

In [127… df.plot()

Out[127… <AxesSubplot: >


In [129… df['A'].plot(kind = 'bar')

Out[129… <AxesSubplot: >

In [131… df.plot(x = 'A', y='B', kind = 'scatter')

Out[131… <AxesSubplot: xlabel='A', ylabel='B'>


In [130… df['A'].plot(kind = 'hist')

Out[130… <AxesSubplot: ylabel='Frequency'>


In [ ]: In [1]: #why do we need visualisation? summarisation of data
#matplotlib, seaborn, plotly, bokeh
#matplotlib>> Matplotlib is a comprehensive library for creating static, animated, and

In [2]: import pandas as pd


import numpy as np
import matplotlib.pyplot as plt

In [3]: #bar, hist, scatter plot, pie chart, line

In [4]: x = np.random.rand(50)
y = np.random.rand(50)

In [5]: x

Out[5]: array([0.04523672, 0.52678624, 0.57524324, 0.32017959, 0.48442014,


0.73400619, 0.71076542, 0.56423514, 0.34838059, 0.06658893,
0.64366268, 0.73815398, 0.9172139 , 0.76201737, 0.4002066 ,
0.74731113, 0.69100191, 0.4439244 , 0.02929531, 0.82891333,
0.98588218, 0.56973437, 0.58333432, 0.91776578, 0.91383099,
0.16790169, 0.48767348, 0.82980882, 0.59680928, 0.38792845,
0.39138941, 0.96058198, 0.59452399, 0.53653046, 0.24683249,
0.05101929, 0.23646572, 0.51956978, 0.55355343, 0.11729102,
0.54589883, 0.8860605 , 0.50266271, 0.0091404 , 0.35141896,
0.95306714, 0.33584584, 0.28434252, 0.87815803, 0.52260635])

In [6]: y

Out[6]: array([0.73698061, 0.98277802, 0.03611394, 0.06617539, 0.07123898,


0.16568321, 0.04548929, 0.62589032, 0.14647129, 0.50208998,
0.09996937, 0.50900122, 0.08079532, 0.69794716, 0.32704163,
0.41690083, 0.10013573, 0.65649297, 0.10738925, 0.86043449,
0.75324767, 0.26143319, 0.72520091, 0.0894082 , 0.46520536,
0.26237297, 0.96765614, 0.742831 , 0.86534412, 0.6662345 ,
0.37864145, 0.22408526, 0.63930028, 0.07181247, 0.75889028,
0.20187134, 0.07532937, 0.45492099, 0.79583278, 0.06072711,
0.29307475, 0.31794915, 0.7241517 , 0.76023021, 0.77459806,
0.46739387, 0.56140306, 0.37085004, 0.2846484 , 0.73373756])

In [7]: plt.scatter(x,y) #To understand the relationship between two variables

Out[7]: <matplotlib.collections.PathCollection at 0x187ff7fbf50>


In [10]: df.plot(figsize = (20, 8))

Out[10]: <Axes: >

In [11]: #line plot


#whenever time component is involved on x axis
#depict the relation between two variables in the trend

In [8]: df = pd.DataFrame(np.random.randn(1000), columns = ['data'], index = pd.date_range x = [1, 2, 3, 4, 5]


y = [5, 1, 7, 8, 2]

In [9]: df plt.plot(x, y)

Out[9]: data
Out[11]: [<matplotlib.lines.Line2D at 0x187801c0350>]
2024-03-29 0.139326

2024-03-30 -0.269635

2024-03-31 -0.744394

2024-04-01 0.232519

2024-04-02 0.112398

... ...

2026-12-19 -1.029113

2026-12-20 -0.472041

2026-12-21 -0.631387

2026-12-22 -0.469771

2026-12-23 -0.072284

1000 rows × 1 columns


In [12]: plt.plot(x, y)
plt.title("line plot to understand the syntax")
plt.xlabel("x points") In [13]: plt.plot(x, y, color = "red")
plt.ylabel("y points") plt.title("line plot to understand the syntax")
plt.show() plt.xlabel("x points")
plt.ylabel("y points")
plt.show()
In [14]: plt.plot(x, y, color = "red", marker = "o") In [15]: plt.plot(x, y, color = "red", marker = "o", linestyle = '--')
plt.title("line plot to understand the syntax") plt.title("line plot to understand the syntax")
plt.xlabel("x points") plt.xlabel("x points")
plt.ylabel("y points") plt.ylabel("y points")
plt.show() plt.show()
In [16]: plt.plot(x, y, color = "red", marker = "o", linestyle = '--', linewidth = 3) In [17]: plt.plot(x, y, color = "red", marker = "o", linestyle = '--', linewidth = 3, markersiz
plt.title("line plot to understand the syntax") plt.title("line plot to understand the syntax")
plt.xlabel("x points") plt.xlabel("x points")
plt.ylabel("y points") plt.ylabel("y points")
plt.show() plt.show()
In [18]: plt.plot(x, y, color = "red", marker = "o", linestyle = '--', linewidth = 3, markersize In [19]: x = [1, 2, 3, 4, 5]
plt.title("line plot to understand the syntax") y1 = [5, 1, 7, 8, 2]
plt.xlabel("x points") y2 = [7, 8, 3, 5, 1]
plt.ylabel("y points")
plt.grid()
plt.show() plt.plot(x, y1, color = "red", marker = "o", linestyle = '--', linewidth = 3, markersi
plt.plot(x, y2, color = "b", marker = "o", linestyle = '--', linewidth = 3, markersize

plt.xlabel("x data axis")


plt.ylabel("y data axis")

plt.title("Multiple lines in one plot")


plt.legend()

plt.show()
plt.plot(x, np.cos(x))

Out[22]: [<matplotlib.lines.Line2D at 0x187806aa2d0>]

In [20]: x = np.linspace(0, 10, 100)


In [23]: plt.plot(x, np.sin(x), '--')
In [21]: x
Out[23]: [<matplotlib.lines.Line2D at 0x187802d0450>]
Out[21]: array([ 0. , 0.1010101 , 0.2020202 , 0.3030303 , 0.4040404 ,
0.50505051, 0.60606061, 0.70707071, 0.80808081, 0.90909091,
1.01010101, 1.11111111, 1.21212121, 1.31313131, 1.41414141,
1.51515152, 1.61616162, 1.71717172, 1.81818182, 1.91919192,
2.02020202, 2.12121212, 2.22222222, 2.32323232, 2.42424242,
2.52525253, 2.62626263, 2.72727273, 2.82828283, 2.92929293,
3.03030303, 3.13131313, 3.23232323, 3.33333333, 3.43434343,
3.53535354, 3.63636364, 3.73737374, 3.83838384, 3.93939394,
4.04040404, 4.14141414, 4.24242424, 4.34343434, 4.44444444,
4.54545455, 4.64646465, 4.74747475, 4.84848485, 4.94949495,
5.05050505, 5.15151515, 5.25252525, 5.35353535, 5.45454545,
5.55555556, 5.65656566, 5.75757576, 5.85858586, 5.95959596,
6.06060606, 6.16161616, 6.26262626, 6.36363636, 6.46464646,
6.56565657, 6.66666667, 6.76767677, 6.86868687, 6.96969697,
7.07070707, 7.17171717, 7.27272727, 7.37373737, 7.47474747,
7.57575758, 7.67676768, 7.77777778, 7.87878788, 7.97979798,
8.08080808, 8.18181818, 8.28282828, 8.38383838, 8.48484848,
8.58585859, 8.68686869, 8.78787879, 8.88888889, 8.98989899,
9.09090909, 9.19191919, 9.29292929, 9.39393939, 9.49494949,
9.5959596 , 9.6969697 , 9.7979798 , 9.8989899 , 10. ])

In [22]: plt.plot(x, np.sin(x))


In [25]: plt.plot(x, np.sin(x), '.-')

Out[25]: [<matplotlib.lines.Line2D at 0x187806e79d0>]

In [24]: plt.plot(x, np.sin(x), '-')

Out[24]: [<matplotlib.lines.Line2D at 0x18780721090>]


In [26]: plt.plot(x, np.sin(x), ':')

Out[26]: [<matplotlib.lines.Line2D at 0x1878059cdd0>]


In [27]: plt.figure() In [28]: plt.figure()
plt.subplot(1, 2, 1) plt.subplot(2, 2, 1)
plt.plot(x, np.sin(x)) plt.plot(x, np.sin(x))

plt.subplot(1, 2, 2) plt.subplot(2, 2, 2)
plt.plot(x, np.cos(x)) plt.plot(x, np.cos(x))

plt.show() plt.subplot(2, 2, 3)
plt.plot(x, np.tan(x))

plt.subplot(2, 2, 4)
plt.plot(x, np.cos(x+1))

plt.show()
In [29]: plt.figure() In [30]: plt.plot(x, np.sin(x-0), color = "blue")
plt.subplot(2, 1, 1)
plt.plot(x, np.sin(x)) Out[30]: [<matplotlib.lines.Line2D at 0x18781ed6a90>]

plt.subplot(2, 1, 2)
plt.plot(x, np.cos(x))

plt.show()
In [31]: plt.plot(x, np.sin(x-0), color = 'blue')
plt.ylim(-1.5, 1.5)
plt.xlim(1, 15)
plt.show()

In [33]: plt.plot(x, np.sin(x-0), color = 'blue')


plt.ylim(-1.5, 1.5)
plt.xlim(1, 15)
plt.grid()
plt.show()
In [32]: plt.plot(x, np.sin(x-0), color = 'blue')
plt.ylim(-1.5, 1.5)
plt.xlim(1, 15)
plt.axis('equal')
plt.show()
In [34]: plt.plot(x, np.sin(x-0), color = 'blue')
plt.ylim(-1.5, 1.5)
plt.xlim(1, 15) In [35]: #histogram>> continuous/numerical data distribution

plt.title("basic syntax")
plt.xlabel("x label") data = np.random.randn(1000) #10 bins
plt.ylabel("y label") plt.hist(data, color='r', bins = 20)
plt.axis('equal') plt.show()
plt.grid()
plt.show()
In [38]: data1

Out[38]: array([-1.11134156, 0.44954746, -0.71209574, ..., 0.07241827,


-1.1861498 , 0.42298723])

In [39]: data2

Out[39]: array([ 3.40887938, 3.65712612, 2.69851614, ..., 1.34283136,


1.42032828, -0.06936625])

In [40]: plt.hist([data1, data2], bins = 20, color = ['r', 'b'], label = ['dist1', 'dist2'
plt.xlabel('Values')
plt.ylabel('frequency')
plt.title("stacked histogram")
plt.show()

In [36]: x

Out[36]: array([ 0. , 0.1010101 , 0.2020202 , 0.3030303 , 0.4040404 ,


0.50505051, 0.60606061, 0.70707071, 0.80808081, 0.90909091,
1.01010101, 1.11111111, 1.21212121, 1.31313131, 1.41414141,
1.51515152, 1.61616162, 1.71717172, 1.81818182, 1.91919192,
2.02020202, 2.12121212, 2.22222222, 2.32323232, 2.42424242,
2.52525253, 2.62626263, 2.72727273, 2.82828283, 2.92929293,
3.03030303, 3.13131313, 3.23232323, 3.33333333, 3.43434343,
3.53535354, 3.63636364, 3.73737374, 3.83838384, 3.93939394,
4.04040404, 4.14141414, 4.24242424, 4.34343434, 4.44444444,
4.54545455, 4.64646465, 4.74747475, 4.84848485, 4.94949495,
5.05050505, 5.15151515, 5.25252525, 5.35353535, 5.45454545,
5.55555556, 5.65656566, 5.75757576, 5.85858586, 5.95959596,
6.06060606, 6.16161616, 6.26262626, 6.36363636, 6.46464646,
6.56565657, 6.66666667, 6.76767677, 6.86868687, 6.96969697,
7.07070707, 7.17171717, 7.27272727, 7.37373737, 7.47474747,
7.57575758, 7.67676768, 7.77777778, 7.87878788, 7.97979798,
8.08080808, 8.18181818, 8.28282828, 8.38383838, 8.48484848, In [41]: #scatter plot >> to understand the relationship between two features
8.58585859, 8.68686869, 8.78787879, 8.88888889, 8.98989899,
9.09090909, 9.19191919, 9.29292929, 9.39393939, 9.49494949, x = np.random.rand(50)
9.5959596 , 9.6969697 , 9.7979798 , 9.8989899 , 10. ]) y = np.random.rand(50)

In [37]: #stacked histogram x

data1 = np.random.normal(0, 1, 5000)


data2 = np.random.normal(3, 2, 5000)
Out[41]: array([0.62310656, 0.40336455, 0.59472641, 0.67586492, 0.65118469,
0.76680594, 0.66167269, 0.00530789, 0.47951912, 0.59598726, x = ['a', 'b', 'c', 'd']
0.39687239, 0.95480755, 0.01203725, 0.63245207, 0.66193227, y = [4, 6, 1, 2]
0.10920827, 0.31752998, 0.5062839 , 0.73998372, 0.33433287,
0.70462833, 0.22038494, 0.23513219, 0.55579573, 0.19175543,
0.27869464, 0.3052211 , 0.23334197, 0.13987511, 0.75334899, plt.bar(x, y, color = 'r')
0.26126477, 0.68513926, 0.68525783, 0.67531933, 0.05979578,
0.80630205, 0.21899882, 0.14420183, 0.02207371, 0.050267 , Out[44]: <BarContainer object of 4 artists>
0.48758227, 0.16436772, 0.47849692, 0.41968418, 0.49510933,
0.16816315, 0.86030286, 0.27515067, 0.90955822, 0.52247516])

In [42]: y

Out[42]: array([0.74406105, 0.0561467 , 0.21390797, 0.97387232, 0.8799093 ,


0.85680637, 0.68549095, 0.87431407, 0.61924468, 0.00402285,
0.94743189, 0.02377763, 0.97847841, 0.03755626, 0.89974618,
0.61732462, 0.82735471, 0.96168341, 0.74934423, 0.97216979,
0.36485344, 0.61288301, 0.05703085, 0.21445652, 0.83653546,
0.81889231, 0.12849367, 0.55462629, 0.80326345, 0.80070413,
0.78813392, 0.35492401, 0.30825885, 0.39247687, 0.92232772,
0.69104145, 0.17079068, 0.59489985, 0.12255304, 0.19317578,
0.42429495, 0.98890271, 0.24583387, 0.15093428, 0.87263938,
0.66185299, 0.51386825, 0.14275447, 0.14539784, 0.80034669])

In [43]: plt.scatter(x, y, c = 'r', marker = 'X')

Out[43]: <matplotlib.collections.PathCollection at 0x1878059e050>

In [45]: x = ['a', 'b', 'c', 'd']


y = [4, 6, 1, 2]

plt.barh(x, y, color = 'r')

Out[45]: <BarContainer object of 4 artists>

In [44]: #bar plot >> To see the distribution of categorical variables


In [46]: #pie chart >> To understand the percnt dist of data In [47]: explode = (0.0, 0.1, 0.1)

langs = ['C', 'Python', 'Java'] langs = ['C', 'Python', 'Java']


students = [20, 100, 40] students = [20, 100, 40]

plt.pie(students, labels = langs, autopct = '%1.1f%%') plt.pie(students, labels = langs, autopct = '%1.1f%%', explode = explode, shadow
plt.title("Pie chart") plt.title("Pie chart")
plt.show() plt.show()
In [49]: data = pd.read_csv("Bank_Churn.csv")
In [48]: #3d plot
data

x = np.random.rand(20)
Out[49]: RowNumber CustomerId Surname CreditScore Geography Gender Age
y = np.random.rand(20)
z = np.random.rand(20) 0 1 15634602 Hargrave 619 France Female 42

1 2 15647311 Hill 608 Spain Female 41


fig = plt.figure()
2 3 15619304 Onio 502 France Female 42
ax = fig.add_subplot(projection = '3d')
ax.scatter(x, y, z, c='red') 3 4 15701354 Boni 699 France Female 39

Out[48]: <mpl_toolkits.mplot3d.art3d.Path3DCollection at 0x18782286050> 4 5 15737888 Mitchell 850 Spain Female 43

... ... ... ... ... ... ... ...

9995 9996 15606229 Obijiaku 771 France Male 39

9996 9997 15569892 Johnstone 516 France Male 35

9997 9998 15584532 Liu 709 France Female 36

9998 9999 15682355 Sabbatini 772 Germany Male 42

9999 10000 15628319 Walker 792 France Female 28

10000 rows × 14 columns

In [50]: plt.scatter(x = data['Age'], y=data['Balance'])

Out[50]: <matplotlib.collections.PathCollection at 0x18783470e50>


In [52]: plt.hist(data['Age'], color='red')

Out[52]: (array([ 611., 2179., 3629., 1871., 828., 523., 208., 127., 20.,
4.]),
array([18. , 25.4, 32.8, 40.2, 47.6, 55. , 62.4, 69.8, 77.2, 84.6, 92. ]),
<BarContainer object of 10 artists>)

In [51]: data.plot.scatter(x = 'Age', y = 'Balance')

Out[51]: <Axes: xlabel='Age', ylabel='Balance'>

In [53]: plt.hist(data['Balance'], color='red')

Out[53]: (array([3.623e+03, 6.900e+01, 3.600e+02, 1.173e+03, 2.081e+03, 1.747e+03,


7.290e+02, 1.860e+02, 3.000e+01, 2.000e+00]),
array([ 0. , 25089.809, 50179.618, 75269.427, 100359.236,
125449.045, 150538.854, 175628.663, 200718.472, 225808.281,
250898.09 ]),
<BarContainer object of 10 artists>)
In [55]: plt.violinplot(data['Balance'])

Out[55]: {'bodies': [<matplotlib.collections.PolyCollection at 0x18781f79150>],


'cmaxes': <matplotlib.collections.LineCollection at 0x18781f44150>,
'cmins': <matplotlib.collections.LineCollection at 0x18781f46110>,
'cbars': <matplotlib.collections.LineCollection at 0x18781ef3ad0>}

In [54]: data.boxplot(column = 'Balance')

Out[54]: <Axes: >

#areaplot An area plot, also called a stacked area plot, is a type of data visualization that shows how
various quantitative factors have changed over time while highlighting how they all work together to
form the whole. It's particularly good for illustrating how elements of a whole change over time or along
a continuous dimension. A layered representation of the data is produced in an area plot by layering
many variables on top of one another. The cumulative influence of all levels provides insight into the
overall trend. Each layer represents a separate category or variable. To distinguish between categories,
the space beneath each layer is frequently colored.

In [56]: import matplotlib.pyplot as plt

# Sample data
years = [2021, 2018, 2022, 2023, 2017]
category1 = [20, 25, 30, 28, 35]
category2 = [10, 15, 20, 18, 25]
category3 = [5, 8, 10, 9, 15]

# Create a area plot


plt.stackplot(years, category1, category2, category3, labels=['Category 1', 'Category
colors=['skyblue', 'lightgreen', 'orange'])

# Add labels and title


plt.xlabel("Years")
plt.ylabel("Values")
plt.title("Area Plot")
plt.legend() In [1]: import pandas as pd
import numpy as np
plt.show() import matplotlib.pyplot as plt
import seaborn as sns

import warnings
warnings.filterwarnings("ignore")

In [2]: #seaborn: statistical data visualization

In [3]: sns.get_dataset_names()

Out[3]: ['anagrams',
'anscombe',
'attention',
'brain_networks',
'car_crashes',
'diamonds',
'dots',
'dowjones',
'exercise',
'flights',
'fmri',
'geyser',
'glue',
'healthexp',
'iris',
'mpg',
'penguins',
'planets',
'seaice',
In [ ]: 'taxis',
'tips',
'titanic']

In [4]: df = sns.load_dataset('tips')

In [5]: df
Out[5]: total_bill tip sex smoker day time size

0 16.99 1.01 Female No Sun Dinner 2

1 10.34 1.66 Male No Sun Dinner 3

2 21.01 3.50 Male No Sun Dinner 3

3 23.68 3.31 Male No Sun Dinner 2

4 24.59 3.61 Female No Sun Dinner 4

... ... ... ... ... ... ... ...

239 29.03 5.92 Male No Sat Dinner 3

240 27.18 2.00 Female Yes Sat Dinner 2

241 22.67 2.00 Male Yes Sat Dinner 2

242 17.82 1.75 Male No Sat Dinner 2

243 18.78 3.00 Female No Thur Dinner 2

244 rows × 7 columns

In [6]: #numerical data plotting


sns.relplot(x = 'total_bill', y = 'tip', data=df) #the relationship between two variables, by default it gives scatterplot, kind='line'

Out[6]: <seaborn.axisgrid.FacetGrid at 0x1caf17bd650>

In [7]: sns.scatterplot(x = df.total_bill, y=df.tip, data=df, hue = 'smoker')

Out[7]: <Axes: xlabel='total_bill', ylabel='tip'>


In [8]: #as the bill increase, the tip also increases
#highest tip was paid by a smoker
sns.relplot(x = 'total_bill', y = 'tip', data=df, hue = 'smoker')
In [9]: df
Out[8]: <seaborn.axisgrid.FacetGrid at 0x1caf191ea50>
Out[9]: total_bill tip sex smoker day time size

0 16.99 1.01 Female No Sun Dinner 2

1 10.34 1.66 Male No Sun Dinner 3

2 21.01 3.50 Male No Sun Dinner 3

3 23.68 3.31 Male No Sun Dinner 2

4 24.59 3.61 Female No Sun Dinner 4

... ... ... ... ... ... ... ...

239 29.03 5.92 Male No Sat Dinner 3

240 27.18 2.00 Female Yes Sat Dinner 2

241 22.67 2.00 Male Yes Sat Dinner 2

242 17.82 1.75 Male No Sat Dinner 2

243 18.78 3.00 Female No Thur Dinner 2

244 rows × 7 columns

In [10]: sns.relplot(x = 'total_bill', y = 'tip', data=df, hue = 'size')

Out[10]: <seaborn.axisgrid.FacetGrid at 0x1caf19e63d0>

In [11]: sns.relplot(x = 'total_bill', y = 'tip', data=df, style = 'size',)

Out[11]: <seaborn.axisgrid.FacetGrid at 0x1caf1a80410>


In [12]: sns.relplot(x = 'total_bill', y = 'tip', data=df, style = 'smoker', hue = 'time' In [13]: #relplot to make a line plot>> we generated a data

Out[12]: <seaborn.axisgrid.FacetGrid at 0x1caf1ac4cd0> time = np.arange(500)


value = np.random.randn(500).cumsum()
df = pd.DataFrame({'time': time, 'value':value})

In [14]: df
Out[14]: time value

0 0 1.034972

1 1 4.242024

2 2 2.310250

3 3 2.014738

4 4 0.929523

... ... ...

495 495 -23.032875

496 496 -23.330670

497 497 -21.830957

498 498 -21.986650

499 499 -20.668398

500 rows × 2 columns

In [15]: sns.relplot(x = 'time', y='value', kind = 'line', data = df, sort = True)

C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn In [16]: fmri = sns.load_dataset('fmri')
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
In [17]: fmri
with pd.option_context('mode.use_inf_as_na', True):
Out[15]: <seaborn.axisgrid.FacetGrid at 0x1caf1b522d0>
Out[17]: subject timepoint event region signal

0 s13 18 stim parietal -0.017552

1 s5 14 stim parietal -0.080883

2 s12 18 stim parietal -0.081033

3 s11 18 stim parietal -0.046134

4 s10 18 stim parietal -0.037970

... ... ... ... ... ...

1059 s0 8 cue frontal 0.018165

1060 s13 7 cue frontal -0.029130

1061 s12 7 cue frontal -0.004939

1062 s11 7 cue frontal -0.025367

1063 s0 0 cue parietal -0.006899

1064 rows × 5 columns

In [18]: sns.relplot(x = 'timepoint', y='signal', kind = 'line', data=fmri)

C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn In [20]: sns.relplot(x = 'timepoint', y='signal', kind = 'line', data=fmri, ci = 'sd')
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead. C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\axisgrid.py:848: FutureWarni
with pd.option_context('mode.use_inf_as_na', True): ng:
Out[18]: <seaborn.axisgrid.FacetGrid at 0x1caf2053f50>
The `ci` parameter is deprecated. Use `errorbar='sd'` for the same effect.

func(*plot_args, **plot_kwargs)
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
Out[20]: <seaborn.axisgrid.FacetGrid at 0x1caf1d5a510>
In [21]: sns.relplot(x = 'timepoint', y='signal',estimator = None, kind = 'line', data=fmri In [22]: sns.relplot(x = 'timepoint', y='signal', kind = 'line', data=fmri, hue = 'event'

C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\axisgrid.py:848: FutureWarni C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn


ng: ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
The `ci` parameter is deprecated. Use `errorbar='sd'` for the same effect. with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
func(*plot_args, **plot_kwargs) ing: use_inf_as_na option is deprecated and will be removed in a future versio
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn n. Convert inf values to NaN before operating instead.
ing: use_inf_as_na option is deprecated and will be removed in a future versio with pd.option_context('mode.use_inf_as_na', True):
n. Convert inf values to NaN before operating instead. C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1075: FutureWarn
with pd.option_context('mode.use_inf_as_na', True): ing: When grouping with a length-1 list-like, you will need to pass a length-1
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn tuple to get_group in a future version of pandas. Pass `(name,)` instead of `na
ing: use_inf_as_na option is deprecated and will be removed in a future versio me` to silence this warning.
n. Convert inf values to NaN before operating instead. data_subset = grouped_data.get_group(pd_key)
with pd.option_context('mode.use_inf_as_na', True): C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1075: FutureWarn
Out[21]: <seaborn.axisgrid.FacetGrid at 0x1caf20d2510> ing: When grouping with a length-1 list-like, you will need to pass a length-1
tuple to get_group in a future version of pandas. Pass `(name,)` instead of `na
me` to silence this warning.
data_subset = grouped_data.get_group(pd_key)
Out[22]: <seaborn.axisgrid.FacetGrid at 0x1caf331ba10>
In [23]: sns.relplot(x = 'timepoint', y='signal', kind = 'line', data=fmri, hue = 'event' In [24]: sns.relplot(x = 'timepoint', y='signal', kind = 'line', data=fmri, hue = 'event'

C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn


ing: use_inf_as_na option is deprecated and will be removed in a future versio ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead. n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True): with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead. n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True): with pd.option_context('mode.use_inf_as_na', True):
Out[23]: <seaborn.axisgrid.FacetGrid at 0x1caec04b850> Out[24]: <seaborn.axisgrid.FacetGrid at 0x1caec113850>
Out[26]: total_bill tip sex smoker day time size

0 16.99 1.01 Female No Sun Dinner 2

1 10.34 1.66 Male No Sun Dinner 3

2 21.01 3.50 Male No Sun Dinner 3

3 23.68 3.31 Male No Sun Dinner 2

4 24.59 3.61 Female No Sun Dinner 4

... ... ... ... ... ... ... ...

239 29.03 5.92 Male No Sat Dinner 3

240 27.18 2.00 Female Yes Sat Dinner 2

241 22.67 2.00 Male Yes Sat Dinner 2

242 17.82 1.75 Male No Sat Dinner 2

243 18.78 3.00 Female No Thur Dinner 2

244 rows × 7 columns

In [27]: sns.relplot(x = 'total_bill', y = 'tip', hue = 'smoker', data = tips, col = 'time'

Out[27]: <seaborn.axisgrid.FacetGrid at 0x1caf380ca90>

In [25]: tips = sns.load_dataset('tips')

In [26]: tips

In [28]: sns.relplot(x = 'total_bill', y = 'tip', hue = 'smoker', data = tips, col = 'size'

Out[28]: <seaborn.axisgrid.FacetGrid at 0x1caf3a1a2d0>


Out[31]: total_bill tip sex smoker day time size

0 16.99 1.01 Female No Sun Dinner 2

1 10.34 1.66 Male No Sun Dinner 3

2 21.01 3.50 Male No Sun Dinner 3

In [30]: sns.scatterplot(x = 'total_bill', y = 'tip', data = tips) 3 23.68 3.31 Male No Sun Dinner 2

Out[30]: <Axes: xlabel='total_bill', ylabel='tip'> 4 24.59 3.61 Female No Sun Dinner 4

... ... ... ... ... ... ... ...

239 29.03 5.92 Male No Sat Dinner 3

240 27.18 2.00 Female Yes Sat Dinner 2

241 22.67 2.00 Male Yes Sat Dinner 2

242 17.82 1.75 Male No Sat Dinner 2

243 18.78 3.00 Female No Thur Dinner 2

244 rows × 7 columns

In [32]: sns.catplot(x = 'day', y = 'total_bill', data = tips)

C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1075: FutureWarn
ing: When grouping with a length-1 list-like, you will need to pass a length-1
tuple to get_group in a future version of pandas. Pass `(name,)` instead of `na
In [31]: tips me` to silence this warning.
data_subset = grouped_data.get_group(pd_key)
Out[32]: <seaborn.axisgrid.FacetGrid at 0x1caf75e8310>
In [33]: sns.catplot(x = 'day', y = 'total_bill', data = tips, kind = 'swarm') In [34]: sns.catplot(x = 'day', y = 'total_bill', data = tips, kind = 'box')

C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\categorical.py:641: FutureWa


ing: use_inf_as_na option is deprecated and will be removed in a future versio rning: The default of observed=False is deprecated and will be changed to True
n. Convert inf values to NaN before operating instead. in a future version of pandas. Pass observed=False to retain current behavior o
with pd.option_context('mode.use_inf_as_na', True): r observed=True to adopt the future default and silence this warning.
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn grouped_vals = vals.groupby(grouper)
ing: use_inf_as_na option is deprecated and will be removed in a future versio C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\categorical.py:641: FutureWa
n. Convert inf values to NaN before operating instead. rning: The default of observed=False is deprecated and will be changed to True
with pd.option_context('mode.use_inf_as_na', True): in a future version of pandas. Pass observed=False to retain current behavior o
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1075: FutureWarn r observed=True to adopt the future default and silence this warning.
ing: When grouping with a length-1 list-like, you will need to pass a length-1 grouped_vals = vals.groupby(grouper)
tuple to get_group in a future version of pandas. Pass `(name,)` instead of `na Out[34]: <seaborn.axisgrid.FacetGrid at 0x1caf76edf10>
me` to silence this warning.
data_subset = grouped_data.get_group(pd_key)
Out[33]: <seaborn.axisgrid.FacetGrid at 0x1caf761cf50>
In [35]: sns.catplot(x = 'day', y = 'total_bill', data = tips, kind = 'violin') In [36]: sns.catplot(x = 'day', y = 'total_bill', data = tips, kind = 'boxen')

C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\categorical.py:641: FutureWa
rning: The default of observed=False is deprecated and will be changed to True
in a future version of pandas. Pass observed=False to retain current behavior o
r observed=True to adopt the future default and silence this warning.
grouped_vals = vals.groupby(grouper)
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\categorical.py:641: FutureWa
rning: The default of observed=False is deprecated and will be changed to True
in a future version of pandas. Pass observed=False to retain current behavior o
r observed=True to adopt the future default and silence this warning.
grouped_vals = vals.groupby(grouper)
Out[35]: <seaborn.axisgrid.FacetGrid at 0x1caf77aef90>
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\categorical.py:641: FutureWa
rning: The default of observed=False is deprecated and will be changed to True
in a future version of pandas. Pass observed=False to retain current behavior o
r observed=True to adopt the future default and silence this warning.
grouped_vals = vals.groupby(grouper)
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\categorical.py:641: FutureWa
rning: The default of observed=False is deprecated and will be changed to True
in a future version of pandas. Pass observed=False to retain current behavior o
r observed=True to adopt the future default and silence this warning.
grouped_vals = vals.groupby(grouper)
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\categorical.py:1794: FutureW
arning: use_inf_as_na option is deprecated and will be removed in a future vers
ion. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\categorical.py:1794: FutureW
arning: use_inf_as_na option is deprecated and will be removed in a future vers
ion. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\categorical.py:1794: FutureW
arning: use_inf_as_na option is deprecated and will be removed in a future vers
ion. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\categorical.py:1794: FutureW
arning: use_inf_as_na option is deprecated and will be removed in a future vers
ion. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
Out[36]: <seaborn.axisgrid.FacetGrid at 0x1caf785e110>

In [38]: sns.barplot(x = 'day', y = 'total_bill', data = tips)

C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\categorical.py:641: FutureWa
rning: The default of observed=False is deprecated and will be changed to True
in a future version of pandas. Pass observed=False to retain current behavior o
r observed=True to adopt the future default and silence this warning.
grouped_vals = vals.groupby(grouper)
Out[38]: <Axes: xlabel='day', ylabel='total_bill'>
In [39]: sns.jointplot(x = tips.total_bill, y = tips.tip) #raw a plot of two variables with bivariate and univariate graphs.

C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True): In [40]: sns.jointplot(x = tips.total_bill, y = tips.tip, kind = 'reg')
Out[39]: <seaborn.axisgrid.JointGrid at 0x1caf9dad890>
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
Out[40]: <seaborn.axisgrid.JointGrid at 0x1caf9e0aa10>
In [41]: sns.jointplot(x = tips.total_bill, y = tips.tip, kind = 'hex') In [42]: sns.jointplot(x = tips.total_bill, y = tips.tip, kind = "kde") #kernel density estimat

C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn


ing: use_inf_as_na option is deprecated and will be removed in a future versio ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead. n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True): with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead. n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True): with pd.option_context('mode.use_inf_as_na', True):
Out[41]: <seaborn.axisgrid.JointGrid at 0x1cafa1e1490> C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
Out[42]: <seaborn.axisgrid.JointGrid at 0x1cafa600790> Out[43]: total_bill tip sex smoker day time size

0 16.99 1.01 Female No Sun Dinner 2

1 10.34 1.66 Male No Sun Dinner 3

2 21.01 3.50 Male No Sun Dinner 3

3 23.68 3.31 Male No Sun Dinner 2

4 24.59 3.61 Female No Sun Dinner 4

... ... ... ... ... ... ... ...

239 29.03 5.92 Male No Sat Dinner 3

240 27.18 2.00 Female Yes Sat Dinner 2

241 22.67 2.00 Male Yes Sat Dinner 2

242 17.82 1.75 Male No Sat Dinner 2

243 18.78 3.00 Female No Thur Dinner 2

244 rows × 7 columns

In [44]: sns.pairplot(tips)

C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
In [43]: #pairplot >> it will plot all the pairwise relationship btw dataframes
Out[44]: <seaborn.axisgrid.PairGrid at 0x1cafa7ee450>
tips
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1057: FutureWarn
ing: The default of observed=False is deprecated and will be changed to True in
a future version of pandas. Pass observed=False to retain current behavior or o
bserved=True to adopt the future default and silence this warning.
grouped_data = data.groupby(
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1075: FutureWarn
ing: When grouping with a length-1 list-like, you will need to pass a length-1
tuple to get_group in a future version of pandas. Pass `(name,)` instead of `na
me` to silence this warning.
data_subset = grouped_data.get_group(pd_key)
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1057: FutureWarn
ing: The default of observed=False is deprecated and will be changed to True in
a future version of pandas. Pass observed=False to retain current behavior or o
bserved=True to adopt the future default and silence this warning.
grouped_data = data.groupby(
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1075: FutureWarn
ing: When grouping with a length-1 list-like, you will need to pass a length-1
tuple to get_group in a future version of pandas. Pass `(name,)` instead of `na
me` to silence this warning.
data_subset = grouped_data.get_group(pd_key)
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1119: FutureWarn
ing: use_inf_as_na option is deprecated and will be removed in a future versio
n. Convert inf values to NaN before operating instead.
with pd.option_context('mode.use_inf_as_na', True):
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1057: FutureWarn
ing: The default of observed=False is deprecated and will be changed to True in
a future version of pandas. Pass observed=False to retain current behavior or o
bserved=True to adopt the future default and silence this warning.
grouped_data = data.groupby(
C:\Users\ajayk\anaconda3\Lib\site-packages\seaborn\_oldcore.py:1075: FutureWarn
In [45]: sns.pairplot(tips, hue = 'smoker') ing: When grouping with a length-1 list-like, you will need to pass a length-1
tuple to get_group in a future version of pandas. Pass `(name,)` instead of `na
me` to silence this warning.
data_subset = grouped_data.get_group(pd_key)
Out[45]: <seaborn.axisgrid.PairGrid at 0x1cafa8a5690>
In [50]: sns.pairplot(tips, hue = 'smoker', palette = 'coolwarm') In [51]: #boxplot
# https://seaborn.pydata.org/generated/seaborn.color_palette.html
# https://seaborn.pydata.org/tutorial/color_palettes.html sns.boxplot(x = 'day', y = 'total_bill', data = tips, palette = "rainbow")

Out[50]: <seaborn.axisgrid.PairGrid at 0x1cafde6f390> Out[51]: <Axes: xlabel='day', ylabel='total_bill'>


In [55]: tips = tips[['total_bill', 'tip', 'size']]

In [57]: tips.corr()

Out[57]: total_bill tip size

total_bill 1.000000 0.675734 0.598315

tip 0.675734 1.000000 0.489299

size 0.598315 0.489299 1.000000

In [59]: sns.heatmap(tips.corr(), cmap = "coolwarm", annot = True)

Out[59]: <Axes: >

In [53]: sns.boxplot(data = tips, palette = "rainbow", orient = 'h')

Out[53]: <Axes: >

In [61]: df = sns.load_dataset("tips")

In [62]: df
Out[62]: total_bill tip sex smoker day time size In [64]: sns.lmplot(x = 'total_bill', y = 'tip', data=df)

0 16.99 1.01 Female No Sun Dinner 2 Out[64]: <seaborn.axisgrid.FacetGrid at 0x1cafef9ab90>

1 10.34 1.66 Male No Sun Dinner 3

2 21.01 3.50 Male No Sun Dinner 3

3 23.68 3.31 Male No Sun Dinner 2

4 24.59 3.61 Female No Sun Dinner 4

... ... ... ... ... ... ... ...

239 29.03 5.92 Male No Sat Dinner 3

240 27.18 2.00 Female Yes Sat Dinner 2

241 22.67 2.00 Male Yes Sat Dinner 2

242 17.82 1.75 Male No Sat Dinner 2

243 18.78 3.00 Female No Thur Dinner 2

244 rows × 7 columns

In [63]: sns.countplot(x = 'sex', data=df)

Out[63]: <Axes: xlabel='sex', ylabel='count'>

In [69]: sns.lmplot(x = 'total_bill', y = 'tip', data=df, height = 15, aspect = 1)

Out[69]: <seaborn.axisgrid.FacetGrid at 0x1cafee10410>


In [1]: #pip install bokeh

In [2]: import bokeh.io


import bokeh.plotting
bokeh.io.output_notebook()

Loading BokehJS ...

In [3]: from bokeh.sampledata.iris import flowers


from bokeh.plotting import figure, output_file, show

In [4]: flowers

Out[4]: sepal_length sepal_width petal_length petal_width species

0 5.1 3.5 1.4 0.2 setosa

1 4.9 3.0 1.4 0.2 setosa

2 4.7 3.2 1.3 0.2 setosa

3 4.6 3.1 1.5 0.2 setosa

4 5.0 3.6 1.4 0.2 setosa

... ... ... ... ... ...

145 6.7 3.0 5.2 2.3 virginica

146 6.3 2.5 5.0 1.9 virginica

147 6.5 3.0 5.2 2.0 virginica

148 6.2 3.4 5.4 2.3 virginica

149 5.9 3.0 5.1 1.8 virginica

150 rows × 5 columns

In [ ]:
In [6]: output_file('test.html')

p = figure(title = 'test_flower')
p.xaxis.axis_label = "petal_length"
p.yaxis.axis_label = "petal_width"
p.circle(flowers['petal_length'], flowers['petal_width'])
show(p)

In [7]: output_file('test.html')

p = figure(title = 'test_flower')
p.xaxis.axis_label = "petal_length"
p.yaxis.axis_label = "petal_width"
p.line(flowers['petal_length'], flowers['petal_width'])
show(p)

In [9]: x = [1, 2, 3, 4]
y = [3, 8, 4, 7]

output_file("line.html")
p = figure(title = "line chart")
p.line(x, y)
show(p)

In [11]: x = [1, 2, 3, 4]
y = [3, 8, 4, 7]

output_file("line.html")
p = figure(title = "line chart")
p.scatter(x, y, size = 20, fill_color='red', legend_label = "this is my data")
show(p)

In [ ]:

You might also like