20181005case-----np.c_

简介: 1.在pandas里想获取某行的数据,可以用name[[‘列名’,‘列名’]].iloc[行号]例:full_country_stats[[“GDPpercaptial”,“Lifesatisfaction”]].iloc[remove_indices]2.把pandas里的某列数据转换成可以进行运算的矩阵np.c_p[name[‘列名’] ]


1.在pandas里想获取某行的数据,可以用

name[[‘列名’,‘列名’]].iloc[行号]

例:

full_country_stats[[“GDPpercaptial”,“Lifesatisfaction”]].iloc[remove_indices]

2.把pandas里的某列数据转换成可以进行运算的矩阵

np.c_p[name[‘列名’] ]

例:

x = np.c_[country_stats[‘GDP per captial’]]

image.png

3.合并dataframes

1.result = pd.merge(left, right, on=‘key’)

4.透视表data_df.pivot()

pivot_df = data_df.pivot(index=‘userNum’, columns=‘subjectCode’, values=‘score’)

image.png


相关文章
|
2月前
|
Perl
awk '{print $12}' | awk -F "ms" '{sum+=$1}END{printf "avg: %f, total: %d\n", sum/NR, NR}' 啥意思
awk '{print $12}' | awk -F "ms" '{sum+=$1}END{printf "avg: %f, total: %d\n", sum/NR, NR}' 啥意思
29 3
|
6月前
|
Linux Windows
【已解决】ValueError: num_samples should be a positive integer value, but got num_samples=0
【已解决】ValueError: num_samples should be a positive integer value, but got num_samples=0
|
6月前
|
索引 Python
row[i] = col[j] = TrueIndexError: list assignment index out of range
row[i] = col[j] = TrueIndexError: list assignment index out of range
CF489C Given Length and Sum of Digits
CF489C Given Length and Sum of Digits
成功解决but is 0 and 2 (computed from start 0 and end 9223372 over shape with rank 2 and stride-1)
成功解决but is 0 and 2 (computed from start 0 and end 9223372 over shape with rank 2 and stride-1)
rank()、dense-rank()、row-number()的区别
rank()、dense-rank()、row-number()的区别
110 0
TestRange.cs error CS0104: `Range' is an ambiguous reference between `System.Range' and Gtk.Range
TestRange.cs error CS0104: `Range' is an ambiguous reference between `System.Range' and Gtk.Range
181 0
np.random.choice 参数replace
np.random.choice 参数replace
130 0
|
索引 Python
成功解决ValueError: column index (256) not an int in range(256)
成功解决ValueError: column index (256) not an int in range(256)
成功解决ValueError: column index (256) not an int in range(256)