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()

  

posted @ 2020-09-30 16:01  洺剑残虹  阅读(1054)  评论(0编辑  收藏  举报