菜单 学习猿地 - LMONKEY

python dask AttributeError: 'Series' object has no attribute 'sort_values' python dask dataframe series 排序 升序和降序

fee_learnku profile image fee_learnku ・1 min read

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

  

评论 (0)