tdpetrou / learn-pandas Goto Github PK
View Code? Open in Web Editor NEWTutorials on how to use pandas effectively to do data analysis
License: BSD 3-Clause "New" or "Revised" License
Tutorials on how to use pandas effectively to do data analysis
License: BSD 3-Clause "New" or "Revised" License
Hello,
First, thank you so much for these great tutorials. There are a number of warnings regarding the usage of "just the indexing operator" for quite a while and the explanation of .loc and .iloc were tremendously helpful.
I'm writing to recommend that you add an example of assigning a new column from a boolean selection that returns a boolean series in the article on assignment. Take for example, the following:
criteria = df[‘some_col’] > sum_number
criteria.head()
0 True
1 False
2 True
4 True
6 False
Using just the assignment operator...
df['new_col'] = df['some-col'] > some_number
...works but yields the warning:
Try using .loc[row_indexer,col_indexer] = value instead
The closest example I've found in your article is this one:
last_name = pd.Series(data=['Smith', 'Jones', 'Williams', 'Green', 'Brown', 'Simpson', 'Peters'],
index=['Tom', 'Niko', 'Penelope', 'Aria', 'Sofia', 'Dean', 'Zach'])
last_name
df['last_name'] = last_name
However, at least in Pandas 0.19.2, this will still yield the same error. After searching around a bit I found this stack overflow discussion which states that after Pandas 0.16.0, the best way to do this is to use the assign function in the following manner:
criteria = df[‘some_col’] > sum_number
df_three.assign(new_col_name = criteria) #note: no quotes on new_col_name
Which seems to work well for me.
Alternatively, I suppose you can simply add which version the tutorial was written under.
Thanks again for this wonderful guide!
Thank you for the tutorials!
I think there's a typo in Exercise 13 of 02 Boolean Indexing.ipynb: it reads "Get the same exact result as exercise 11", but probably should read "Get the same exact result as exercise 12".
great read!
fix .loc --> .iloc in line 4596
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.