import numpy as np
arr = np.random.randint(230,400, size=[3, 3])
for i in range(arr.shape[1]):
print("В "+str(i)+"-ом столбце максимальный элемент:", arr.max(axis=0)[i])
for i in range(arr.shape[1]):
print("В "+str(i)+"-ом столбце максимальный элемент:", arr[:,i].max())
array([[263, 333, 334],
[278, 383, 307],
[328, 255, 314]])
В 0-ом столбце максимальный элемент: 328
В 1-ом столбце максимальный элемент: 383
В 2-ом столбце максимальный элемент: 334
lt= ['abc', 'apple', 'pen', 'abc', 'pen', 'pc']
lt_num=[sorted(list(set(lt))).index(x) for x in lt]
[0, 1, 3, 0, 3, 2]
df['d1']=df.convert_dtypes().sum(axis=1)
a b c d1
I 1 2 3 3.0
II 4 5 6 9.0
III 7 8 9 15.0
import sys
'pandas' in sys.modules
x = np.linspace(0, 5, 11)
y = x**2
fig, ax = plt.subplots()
ax.plot(x, y, 'r')
ax.spines['bottom'].set_linewidth(10)
plt.rcParams.update({'font.size': 48})
a,b=map(int,input().split())
a==np.array([0])
b==np.array([0])
a,b=map(int,input().split())
k,e=map(int,input().split())
x,y=map(int,input().split())
c=a-b
d=k-e
g=x-y
r=c+d+g
print(-r)
import os
path=os.getcwd()
os.chdir(path)
os.system(command)
list_a = [["Федя",'Boston Celtics'],
["Петя",'Toronto Raptors'],
["Коля",'Toronto Raptors'],
["Вася", 'Молодые таланты'],
["Онуфрий",'Старые инвалиды']]
columns = ['Name', 'Team']
nba = pd.DataFrame(list_a, columns=columns)
west = ['Boston Celtics', 'Brooklyn Nets', 'New York Knicks',
'Philadelphia 76ers', 'Toronto Raptors', 'Chicago Bulls', 'Cleveland Cavaliers',
'Detroit Pistons', 'Indiana Pacers', 'Milwaukee Bucks', 'Charlotte Hornets',
'Miami Heat', 'Orlando Magic',
'Washington Wizards', 'Minnesota Timberwolves']
nba['conference']=np.where(nba['Team'].isin(west), 'western','eastern' )
print(nba)
Name Team conference
0 Федя Boston Celtics western
1 Петя Toronto Raptors western
2 Коля Toronto Raptors western
3 Вася Молодые таланты eastern
4 Онуфрий Старые инвалиды eastern
import numpy as np
an=np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]])
bn=np.empty(shape=(an.shape[1],an.shape[0]))
for i in range(an.shape[0]):
for j in range(an.shape[1]):
bn[j,an.shape[0]-1-i]=an[i,j]
array([[ 1, 2, 3, 4],
[ 5, 6, 7, 8],
[ 9, 10, 11, 12]])
array([[ 9., 5., 1.],
[10., 6., 2.],
[11., 7., 3.],
[12., 8., 4.]])
n=3
m=4
a=[[1,2,3,4],[5,6,7,8],[9,10,11,12]]
k=[[0,0,0],[0,0,0],[0,0,0],[0,0,0]]
for i in range(n):
for j in range(m):
k[j][n-1-i]=a[i][j]
[[9, 5, 1],
[10, 6, 2],
[11, 7, 3],
[12, 8, 4]]