Python pandas DataFrame操作,,1. 从字典创建Da
Python pandas DataFrame操作,,1. 从字典创建Da
1. 从字典创建Dataframe
>>> import pandas as pd>>> dict1 = {‘col1‘:[1,2,5,7],‘col2‘:[‘a‘,‘b‘,‘c‘,‘d‘]}>>> df = pd.DataFrame(dict1)>>> df col1 col20 1 a1 2 b2 5 c3 7 d
2. 从多个列表创建Dataframe (先把列表转化为字典,再把字典转化为DataFrame)
>>> lista = [1,2,5,7]>>> listb = [‘a‘,‘b‘,‘c‘,‘d‘]>>> df = pd.DataFrame({‘col1‘:lista,‘col2‘:listb})>>> df col1 col20 1 a1 2 b2 5 c3 7 d
Python pandas DataFrame操作
相关内容
- Mac&Appium&Python自动化测试-环境搭建之安卓
- Python重写C语言程序100例--Part7,python--part7,‘‘‘【程序
- python执行shell指令的几种方法,pythonshell,1.os.syste
- 粗解python的@classmethod和@staticmethod及普通实例方法,,引
- Python 代码优化基础——判断对象类型,,# -*- codi
- python前端HTML和CSS进阶,pythoncss进阶,知识点预习1.列表
- mysql与python3交互,,ubuntu端安装s
- PYTHON访问数据库,,PYTHON DB
- python改文件名,python文件名,import os
- Python学习基础:If 语句与 While 语句,pythonwhile,If 语句用
评论关闭