Python Syntax
Recommended Reading : 【Python】 Python Table of Contents
1. Overview
2. Syntax
a. R Overview
1. Overview
⑴ Advantage 1. Easy to implement backend in app development, etc.
⑵ Advantage 2. Well-developed deep learning tools
⑶ Advantage 3. Various applications possible based on open community
⑷ Advantage 4. Excellent data visualization
2. Syntax
⑴ Python can return multiple values simultaneously
⑵ yield returns values one at a time when needed, rather than all at once
⑶ You can write multi-line code by using backspace \ for line breaks
⑷ A single-line string is represented by “~” or ‘~’, and a multi-line string is represented by “””~””” or ‘’’~’’’
⑸ adata.var_names=[i.upper() for i in list(adata.var_names)]
① Meaning : In adata.var_names, each i in list(data.var_names) is stored in uppercase
⑹ if issparse(counts.X):counts.X=counts.X.A
① Meaning : If counts.X is a sparse matrix, the value of counts.X.A is assigned to counts.X
⑺ pd.DataFrame([(str(i),str(j)) for i in range(4) for j in range(i+1, 4)])
0 1
0 0 1
1 0 2
2 0 3
3 1 2
4 1 3
5 2 3
⑻ Broadcasting
① A feature in NumPy that allows operations between arrays of mismatched dimensions
② A small array (as long as it has a dimension of 1) is automatically expanded to match the larger array’s shape, and then the operation is performed
③ Data is not physically copied to match the small array to the large array
# Shape of `exp_log_mu`: (2257, 6)
# Shape of `theta_mn`: (6, 13344)
exp_log_mu_expanded = exp_log_mu[:, :, np.newaxis] # Shape: (2257, 6, 1)
theta_mn_expanded = theta_mn[np.newaxis, :, :] # Shape: (1, 6, 13344)
result = exp_log_mu_expanded * theta_mn_expanded # Shape: (2257, 6, 13344)
Input: 2024.04.30 13:41