您的位置:首页 > 其它

pandas module 1 - cookbook

2016-07-15 22:13 344 查看


1. Idioms(习语)

(1)if-then on one column



(2)if-then with assignment to 2 columns



(3)to do the -else



(4)use the mask



(5)if-then-else using numpy's where()



(6)Split a frame with a boolean criterion



(7) Select with multi-column criteria



(8)select rows with data closest to certain value using argsort



(9)Dynamically reduce a list of criteria using a binary operators




2. Selection

1. DataFrame

(1) Using both row labels and value conditionals



(2)Use loc or iloc slicing



(3)using (~) to make a mask



2. Pannels(面板) -- adding a new dimension 



3. creating a new columns (applymap)



4. keep other columns when using min() with groupby




3. Multi-Indexing

1. creating a multi-index from a labeled frame





2. Performing arthmetic with a multi-index that needs broadcasting



3. slicing a multi-index with xs method1



4. sort with a multi-index




4. Missing Data

Fill forward a reversed timeseries




5. Grouping

1. Basic grouping with apply



2. using get_group



3. In a group apply to different items



4. Expanding apply



5. Replacing some values



6. sort groups by aggregated(聚合) data



7. create multiple aggregated columns



8. create a value counts column and reassign back to the DataFrame



9. shift groups in a column



10. select row with max value from each group



11. grouping like python's itertools.groupby



12. create a list of dataframes, split using a delineation based on logic included in rows



13. partial sums(部分和) and subtotals(小计)



14. frequency table like plyr in R



15. using apply to turning embeded lists into a multi-index frame



16. Rolling apply with a DataFrame returning a Series



17. rolling apply with a DataFrame returning a Scalar(Volume Weighted Average Price)




6. Timeseries

1. calculate the first day of the month for each entry in a DatetimeIndex




7. Merge

1. append two dataframes with overlapping index



2. self join of a dataframe




8. Plotting








9. Data In/Out

1. CSV

(1) sample



(2) skip row between beader and data





2. 二进制文件








10. Timedeltas

1. using time deltas





2. datetime can be set to NaT



4000
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  panda