简单操作 Python-层次聚类-Hierarchical clustering >>> data = pd.Series(np.random.randn(10),index=[['a','a','a','b','b','c','c','d','d','d'],[1,2,3,1,2,1,2,3,1,2]]) >>> data a 1 -0.168871 2 0.828841 3 0.786215 b 1 0.506081 2 -2.304898 c 1 0.864875…
pandas大家用的都很多,像我这种用的不够熟练,也不够多的就只能做做笔记,尽量留下点东西吧. 筛选行: a. 按照列的条件筛选 df = pandas.DataFrame(...) # supposing it has 3 columns: a, b and c df[(df['a'] > 0) & (df['b'] < 0) | df['c'] > 0] b. 按照索引的条件筛选 needed_seq=[1,2,3,6] needed_df = df.loc[needed_s…