Git Product home page Git Product logo

leetcode_python's Introduction

Cheat Sheet

slicing: nums[a,b]左闭右开,对应index: a到(b-1),对应1-based position: (a+1)到b

range: range(a,b)左闭右开,表示a到b-1(所以nums[a,b]相当于用range(a,b)生成index a到(b-1), 然后调用index对应的position (a+1)到b)

pandas.DataFrame: df[a:b] and df.iloc[a:b, :]都是左闭右开,取index: a到b-1的行

所以,只用记得code中的范围左闭右开后就是index范围,不要老想实际位置,只要记得位置等于index+1就行了

特例: df.loc在slice时包含start和end df.loc[2:5, :]表示index为2到5的行,所以左右都是闭区间
而要回到iloc的范围的话就得使用df.loc[df.index[2:5], :],即先利用普通slice的左闭右开性质,取df.index中的2到4,强行去掉5 (df.index是一个RangeIndex data type)
note: 若非特殊说明,以上都是在讲index (start from 0)

#48 如果是顺时针旋转90度,transpose, then reverse order within each row (equivalently, 先reverse within each column再transpose) 如果是逆时针旋转90度,transpose, then reverse order within each column

leetcode_python's People

Contributors

ysfei avatar princewen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.