查看DA的源代码
←
DA
跳转到:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您刚才请求的操作只有这个用户组中的用户才能使用:
用户
您可以查看并复制此页面的源代码:
== Pandas == 插入行: <source lang=python> >>> idx = pd.to_datetime(d['date'],format='%Y%m%d') >>> us.loc[idx] = [d['positive'], , d['death'], 0] </source> 删除行: <source lang=python> >>> us.index[-1] Timestamp('2020-03-18 00:00:00') >>> us.index[[-1, -2]] Index([2020-03-18 00:00:00, 1970-01-01 00:00:00.020200318], dtype='object', name='Date') >>> us.drop(us.index[-2], inplace=True) # 删除最后一行 >>> us.drop(us.index[[-1,-2]], inplace=True) # 删除最后两行 </source> 增加一列: <source lang=python> >>> u.columns Index(['Confirmed', 'New Confirmed', 'Deaths', 'New Deaths'], dtype='object') >>> u['New Col'] = 2 >>> u.columns Index(['Confirmed', 'New Confirmed', 'Deaths', 'New Deaths', 'New Col'], dtype='object') >>> u.tail() Confirmed New Confirmed Deaths New Deaths New Col Date 2020-03-15 00:00:00 3173 723 60 11 2 2020-03-16 00:00:00 4019 846 71 11 2 </source> 删除列: <source lang=python> >>> u.drop(['New Col'], axis=1, inplace=True) >>> u.columns Index(['Confirmed', 'New Confirmed', 'Deaths', 'New Deaths'], dtype='object') >>> del u['Deaths'] >>> u.columns Index(['Confirmed', 'New Confirmed', 'New Deaths'], dtype='object') </source> <source lang=python> >>> nd = u.pop('New Deaths') >>> nd.tail() Date 2020-03-15 11 2020-03-16 11 Name: New Deaths, dtype: int64 >>> u.tail() Confirmed New Confirmed Date 2020-03-15 00:00:00 3173 723 2020-03-16 00:00:00 4019 846 </source> <br>
返回到
DA
。
个人工具
登录
名字空间
页面
讨论
变换
查看
阅读
查看源代码
查看历史
操作
搜索
导航
首页
社区专页
新闻动态
最近更改
随机页面
帮助
工具箱
链入页面
相关更改
特殊页面