首页| 论坛| 消息
主题:Pandas 速查手册
回帖:常用备忘

# 解决科学计数法问题
df = pd.read_csv('111.csv', sep='\t').fillna('')[:].astype('str')
# 和订单量相关性最大到小显示
dd.corr().total_order_num.sort_values(ascending=False)

# 解析列表、json 字符串
import ast
ast.literal_eval("[{'id': 7, 'name':'Funny'}]")

# Series apply method applies a functionto
# every element in a Series and returnsa Series
ted.ratings.apply(str_to_list).head()
# lambda is a shorter alternative
ted.ratings.apply(lambda x: ast.literal_eval(x))
# an even shorter alternative is toapply the
# function directly (without lambda)
ted.ratings.apply(ast.literal_eval)
# 索引 index 使用 apply()
df.index.to_series().apply()
下一楼›:样式显示
df['per_cost'] = df['per_cost'].map('{:,.2f}%'.format ..
‹上一楼:时间处理 时间序列
df.index = pd.DatetimeIndex(df.index)
# 时间只保留日期
df[&# ..

查看全部回帖(13)
«返回主帖