打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
python笔记
pip install -U --upgrade pandas

  pip show pandas

  pip list

  pip list --outdated

  pip install pandas

  pip uninstall SomePackage

  pip --help

  pip install pkg_name --user

  安装特定版本的package,通过使用==, >=, <=, >, <来指定一个版本号。

  pip install 'Markdown<2.0'

  pip install 'Markdown>2.0,<2.0.3'

  -------------------

  t=[exp for if ]

  t=int(num + 1) if int(num) != num else int(num)

  变量的赋值: 绑定/关联 对象的内存地址id   赋值即定义了变量

  a=b=[1,2,3]

  c=[1,2,3]

  a is b

  a is not c

  a==b

  a==c

  is 对象相同即id值相同

  == 是值相同

  generator

  yield

  def fun1():

  pass

  yiled value1

  pass

  fun1 是一个特殊的function(有迭代功能)

  fun1() 是一个特殊的function object=generator,

  next send 逐次执行

  到yield ,程序暂停,返回 value1 or send过来的其他值,等再次next or send,执行之后的语句

  到 yield,若没有yiled了则抛出StopIteration

  Iterator

  格式限定符

  '字串{:格式}'.format()

  python中变量的交换可以不需要中间变量。

  >>>x,y=1,2

  >>>x,y=y,x

  >>>x

  2

  >>>y

  1

  if [] {} 0 等都是 False

  类型:可变,不可变

  module class attribute method function

  condition

  not conditon

  not '' true

  not 'a' false

  while true:

  name=input()

  if not name :break

  dosomething()

  from collections import Counter

  str.count()

  dfi[1].strftime('%Y-%m-%d')

  Out[15]: '2015-10-02'



  read_excel( index_col=1)

  sr.name sr.index

  df.index df.columns

  df.index.set_names('a') or df.index.name='a'

  df.set_index('date',inplace=True)

  df.set_index(pd.date_range('2015.10.1',periods=len(df)))

  df.index=df.date

  df.index=df['column1']

  var1=df['columns1']

  df['column1']的其中一个元素变,df.index var1对应也变

  df.index=df['column1'].copy(True) deepcopy就不会了。默认就是deepcopy

  copy deepcopy

  datetime_obj.strftime('')

  df.date=pd.to_datetime(df['date'])

  ---------------------------------------------------------

  df.groupby(func1) index的逐个元素作为func1的参数

  g=df.groupby(df['a'].apply(lambda x:x>0))

  g=df.groupby(df['a'].map(lambda x:x>0))

  g=df.groupby(df['a']>0)

  g=df.groupby(pd.Series(['a','a','b','c'])

  df.groupby(cut())

  df.groupby(qcut())

  dataframegroupby.agg transform apply

  -----------------------------------------------------------

  np.random.randn(2,4)

  np.arange(10).reshape(5,2)

  range(10)

  ---------------------------

  dfp3=pd.pivot_table(df,columns=['品名','型号'],aggfunc=np.sum)

  dfp3=pd.pivot_table(df,columns='型号',aggfunc=np.sum)

  or

  dfp3=df.pivot_table(columns=['品名','型号'],aggfunc=np.sum)

------------------

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Python数据分析,办公自动化,如何数据分组与透视?
对比Excel,学习pandas数据透视表
python pandas 交叉表, 透视表
Python中pandas透视表pivot
Pandas入门(二)
numpy和pandas矢量运算实现sql的功能
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服