zoukankan      html  css  js  c++  java
  • python dask AttributeError: 'Series' object has no attribute 'sort_values' python dask dataframe series 排序 升序和降序

    1、python dask  dataframe  series  升序和降序

    # conding:utf-8
    import time
    import dask.dataframe as dd
    import dask.array as da
    import gc
    
    st = time.time()
    
    # url:str="mysql+pymysql://root:123456@localhost:3306/getonroom"  # &useSSL=true  &serverTimezone=GMT%2B8  useUnicode=true ?characterEncoding=utf-8
    
    # df1:dd.DataFrame = dd.read_sql_table("room1",uri=url,index_col="id")
    # df2:dd.DataFrame = dd.read_sql_table("room2",uri=url,index_col="id",npartitions=4)
    
    df1 = dd.read_csv('./data/room1.csv',sep=',',header=0,encoding='utf-8',dtype='object')
    
    print(type(df1))
    print(df1.columns)
    
    # gen:dd.Series = df1.Gender
    # print(df1.Gender.groupby(df1.Gender).count().size.compute())
    
    re:dd.Series = df1.Gender.groupby(df1.Gender).count()
    n:int = re.size.compute()
    print(n)
    # ds = re.nlargest(n)  # 降序
    ds = re.nsmallest(n)   # 升序
    print(ds.compute())
    
    print(time.time()-st)
    gc.collect()
    

      

  • 相关阅读:
    元组,字典
    python字符串
    tensorflow 学习笔记
    tensorflow example1
    python第二章(2)列表
    python3.5学习第二章(1)标准库,bytes
    类加载过程
    数据值与地址值
    类的初始化与实例化顺序
    SpringCloudBus
  • 原文地址:https://www.cnblogs.com/wuzaipei/p/13755020.html
Copyright © 2011-2022 走看看