文章目录
- 导入数据、查看数据
-
- DataFrame
- 字典转化为DataFrame
- Dataframe的访问
- 设置索引、使用索引
-
- 筛选
-
- 更改数据
- 更新列名
- 更新数据
- apply
- applymap
- map
- replace
- 添加/删除行和列
- 合并列
- 删除列
- 拆分列
- 添加数据
- 合并Dataframe
- 删除行
- 数据排序
- sort_values()
- 按照索引排序
- 查看某列前10大
数据集链接:https://survey.stackoverflow.co/
导入数据、查看数据
import pandas as pd
df = pd.read_csv('data/survey_results_public.csv')
查看前十条
df.head(10)
| Respondent | MainBranch | Hobbyist | OpenSourcer | OpenSource | Employment | Country | Student | EdLevel | UndergradMajor | EduOther | OrgSize | DevType | YearsCode | Age1stCode | YearsCodePro | CareerSat | JobSat | MgrIdiot | MgrMoney | MgrWant | JobSeek | LastHireDate | LastInt | FizzBuzz | JobFactors | ResumeUpdate | CurrencySymbol | CurrencyDesc | CompTotal | CompFreq | ConvertedComp | WorkWeekHrs | WorkPlan | WorkChallenge | WorkRemote | WorkLoc | ImpSyn | CodeRev | CodeRevHrs | UnitTests | PurchaseHow | PurchaseWhat | LanguageWorkedWith | LanguageDesireNextYear | DatabaseWorkedWith | DatabaseDesireNextYear | PlatformWorkedWith | PlatformDesireNextYear | WebFrameWorkedWith | WebFrameDesireNextYear | MiscTechWorkedWith | MiscTechDesireNextYear | DevEnviron | OpSys | Containers | BlockchainOrg | BlockchainIs | BetterLife | ITperson | OffOn | SocialMedia | Extraversion | ScreenName | SOVisit1st | SOVisitFreq | SOVisitTo | SOFindAnswer | SOTimeSaved | SOHowMuchTime | SOAccount | SOPartFreq | SOJobs | EntTeams | SOComm | WelcomeChange | SONewContent | Age | Gender | Trans | Sexuality | Ethnicity | Dependents | SurveyLength | SurveyEase |
|---|
| 0 | 1 | I am a student who is learning to code | Yes | Never | The quality of OSS and closed source software ... | Not employed, and not looking for work | United Kingdom | No | Primary/elementary school | NaN | Taught yourself a new language, framework, or ... | NaN | NaN | 4 | 10 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | HTML/CSS;Java;JavaScript;Python | C;C++;C#;Go;HTML/CSS;Java;JavaScript;Python;SQL | SQLite | MySQL | MacOS;Windows | Android;Arduino;Windows | Django;Flask | Flask;jQuery | Node.js | Node.js | IntelliJ;Notepad++;PyCharm | Windows | I do not use containers | NaN | NaN | Yes | Fortunately, someone else has that title | Yes | Twitter | Online | Username | 2017 | A few times per month or weekly | Find answers to specific questions;Learn how t... | 3-5 times per week | Stack Overflow was much faster | 31-60 minutes | No | NaN | No, I didn't know that Stack Overflow had a jo... | No, and I don't know what those are | Neutral | Just as welcome now as I felt last year | Tech articles written by other developers;Indu... | 14.0 | Man | No | Straight / Heterosexual | NaN | No | Appropriate in length | Neither easy nor difficult |
|---|
| 1 | 2 | I am a student who is learning to code | No | Less than once per year | The quality of OSS and closed source software ... | Not employed, but looking for work | Bosnia and Herzegovina | Yes, full-time | Secondary school (e.g. American high school, G... | NaN | Taken an online course in programming or softw... | NaN | Developer, desktop or enterprise applications;... | NaN | 17 | NaN | NaN | NaN | NaN | NaN | NaN | I am actively looking for a job | I've never had a job | NaN | NaN | Financial performance or funding status of the... | Something else changed (education, award, medi... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | C++;HTML/CSS;Python | C++;HTML/CSS;JavaScript;SQL | NaN | MySQL | Windows | Windows | Django | Django | NaN | NaN | Atom;PyCharm | Windows | I do not use containers | NaN | Useful across many domains and could change ma... | Yes | Yes | Yes | Instagram | Online | Username | 2017 | Daily or almost daily | Find answers to specific questions;Learn how t... | 3-5 times per week | Stack Overflow was much faster | 11-30 minutes | Yes | A few times per month or weekly | No, I knew that Stack Overflow had a job board... | No, and I don't know what those are | Yes, somewhat | Just as welcome now as I felt last year | Tech articles written by other developers;Indu... | 19.0 | Man | No | Straight / Heterosexual | NaN | No | Appropriate in length | Neither easy nor difficult |
|---|
| 2 | 3 | I am not primarily a developer, but I write co... | Yes | Never | The quality of OSS and closed source software ... | Employed full-time | Thailand | No | Bachelor’s degree (BA, BS, B.Eng., etc.) | Web development or web design | Taught yourself a new language, framework, or ... | 100 to 499 employees | Designer;Developer, back-end;Developer, front-... | 3 | 22 | 1 | Slightly satisfied | Slightly satisfied | Not at all confident | Not sure | Not sure | I’m not actively looking, but I am open to new... | 1-2 years ago | Interview with people in peer roles | No | Languages, frameworks, and other technologies ... | I was preparing for a job search | THB | Thai baht | 23000.0 | Monthly | 8820.0 | 40.0 | There's no schedule or spec; I work on what se... | Distracting work environment;Inadequate access... | Less than once per month / Never | Home | Average | No | NaN | No, but I think we should | Not sure | I have little or no influence | HTML/CSS | Elixir;HTML/CSS | PostgreSQL | PostgreSQL | NaN | NaN | NaN | Other(s): | NaN | NaN | Vim;Visual Studio Code | Linux-based | I do not use containers | NaN | NaN | Yes | Yes | Yes | Reddit | In real life (in person) | Username | 2011 | A few times per week | Find answers to specific questions;Learn how t... | 6-10 times per week | They were about the same | NaN | Yes | Less than once per month or monthly | Yes | No, I've heard of them, but I am not part of a... | Neutral | Just as welcome now as I felt last year | Tech meetups or events in your area;Courses on... | 28.0 | Man | No | Straight / Heterosexual | NaN | Yes | Appropriate in length | Neither easy nor difficult |
|---|
| 3 | 4 | I am a developer by profession | No | Never | The quality of OSS and closed source software ... | Employed full-time | United States | No | Bachelor’s degree (BA, BS, B.Eng., etc.) | Computer science, computer engineering, or sof... | Taken an online course in programming or softw... | 100 to 499 employees | Developer, full-stack | 3 | 16 | Less than 1 year | Very satisfied | Slightly satisfied | Very confident | No | Not sure | I am not interested in new job opportunities | Less than a year ago | Write code by hand (e.g., on a whiteboard);Int... | No | Languages, frameworks, and other technologies ... | I was preparing for a job search | USD | United States dollar | 61000.0 | Yearly | 61000.0 | 80.0 | There's no schedule or spec; I work on what se... | NaN | Less than once per month / Never | Home | A little below average | No | NaN | No, but I think we should | Developers typically have the most influence o... | I have little or no influence | C;C++;C#;Python;SQL | C;C#;JavaScript;SQL | MySQL;SQLite | MySQL;SQLite | Linux;Windows | Linux;Windows | NaN | NaN | .NET | .NET | Eclipse;Vim;Visual Studio;Visual Studio Code | Windows | I do not use containers | Not at all | Useful for decentralized currency (i.e., Bitcoin) | Yes | SIGH | Yes | Reddit | In real life (in person) | Username | 2014 | Daily or almost daily | Find answers to specific questions;Pass the ti... | 1-2 times per week | Stack Overflow was much faster | 31-60 minutes | Yes | Less than once per month or monthly | Yes | No, and I don't know what those are | No, not really | Just as welcome now as I felt last year | Tech articles written by other developers;Indu... | 22.0 | Man | No | Straight / Heterosexual | White or of European descent | No | Appropriate in length | Easy |
|---|
| 4 | 5 | I am a developer by profession | Yes | Once a month or more often | OSS is, on average, of HIGHER quality than pro... | Employed full-time | Ukraine | No | Bachelor’s degree (BA, BS, B.Eng., etc.) | Computer science, computer engineering, or sof... | Taken an online course in programming or softw... | 10,000 or more employees | Academic researcher;Developer, desktop or ente... | 16 | 14 | 9 | Very dissatisfied | Slightly dissatisfied | Somewhat confident | Yes | No | I am not interested in new job opportunities | Less than a year ago | Write any code;Write code by hand (e.g., on a ... | No | Industry that I'd be working in;Languages, fra... | I was preparing for a job search | UAH | Ukrainian hryvnia | NaN | NaN | NaN | 55.0 | There is a schedule and/or spec (made by me or... | Being tasked with non-development work;Inadequ... | A few days each month | Office | A little above average | Yes, because I see value in code review | NaN | Yes, it's part of our process | Not sure | I have little or no influence | C++;HTML/CSS;Java;JavaScript;Python;SQL;VBA | HTML/CSS;Java;JavaScript;SQL;WebAssembly | Couchbase;MongoDB;MySQL;Oracle;PostgreSQL;SQLite | Couchbase;Firebase;MongoDB;MySQL;Oracle;Postgr... | Android;Linux;MacOS;Slack;Windows | Android;Docker;Kubernetes;Linux;Slack | Django;Express;Flask;jQuery;React.js;Spring | Flask;jQuery;React.js;Spring | Cordova;Node.js | Apache Spark;Hadoop;Node.js;React Native | IntelliJ;Notepad++;Vim | Linux-based | Outside of work, for personal projects | Not at all | NaN | Yes | Also Yes | Yes | Facebook | In real life (in person) | Username | I don't remember | Multiple times per day | Find answers to specific questions | More than 10 times per week | Stack Overflow was much faster | NaN | Yes | A few times per month or weekly | No, I knew that Stack Overflow had a job board... | No, I've heard of them, but I am not part of a... | Yes, definitely | Just as welcome now as I felt last year | Tech meetups or events in your area;Courses on... | 30.0 | Man | No | Straight / Heterosexual | White or of European descent;Multiracial | No | Appropriate in length | Easy |
|---|
| 5 | 6 | I am not primarily a developer, but I write co... | Yes | Never | The quality of OSS and closed source software ... | Employed full-time | Canada | No | Bachelor’s degree (BA, BS, B.Eng., etc.) | Mathematics or statistics | Taken an online course in programming or softw... | NaN | Data or business analyst;Data scientist or mac... | 13 | 15 | 3 | Very satisfied | Slightly satisfied | Very confident | No | Yes | I am not interested in new job opportunities | 1-2 years ago | Write any code;Complete a take-home project;In... | No | Financial performance or funding status of the... | I heard about a job opportunity (from a recrui... | CAD | Canadian dollar | 40000.0 | Monthly | 366420.0 | 15.0 | There's no schedule or spec; I work on what se... | NaN | A few days each month | Home | A little above average | No | NaN | Yes, it's not part of our process but the deve... | Not sure | I have little or no influence | Java;R;SQL | Python;Scala;SQL | MongoDB;PostgreSQL | PostgreSQL | Android;Google Cloud Platform;Linux;Windows | Android;Google Cloud Platform;Linux;Windows | NaN | NaN | Hadoop | Hadoop;Pandas;TensorFlow;Unity 3D | Android Studio;Eclipse;PyCharm;RStudio;Visual ... | Windows | I do not use containers | Not at all | NaN | No | Yes | No | YouTube | In real life (in person) | Login | 2011 | A few times per month or weekly | Find answers to specific questions | Less than once per week | Stack Overflow was slightly faster | 60+ minutes | Yes | I have never participated in Q&A on Stack Over... | No, I knew that Stack Overflow had a job board... | No, and I don't know what those are | No, not really | Just as welcome now as I felt last year | Tech articles written by other developers;Indu... | 28.0 | Man | No | Straight / Heterosexual | East Asian | No | Too long | Neither easy nor difficult |
|---|
| 6 | 7 | I am a developer by profession | No | Never | The quality of OSS and closed source software ... | Independent contractor, freelancer, or self-em... | Ukraine | No | Bachelor’s degree (BA, BS, B.Eng., etc.) | Another engineering discipline (ex. civil, ele... | Taught yourself a new language, framework, or ... | Just me - I am a freelancer, sole proprietor, ... | Designer;Developer, front-end | 6 | 17 | 4 | Slightly satisfied | Neither satisfied nor dissatisfied | NaN | NaN | NaN | I’m not actively looking, but I am open to new... | NA - I am an independent contractor or self em... | Write any code | No | Remote work options;Opportunities for professi... | NaN | USD | United States dollar | NaN | NaN | NaN | 32.0 | There is a schedule and/or spec (made by me or... | Being tasked with non-development work;Distrac... | All or almost all the time (I'm full-time remote) | Other place, such as a coworking space or cafe | Average | Yes, because I see value in code review | 6.0 | NaN | NaN | NaN | HTML/CSS;JavaScript | HTML/CSS;JavaScript | NaN | NaN | MacOS;Windows | MacOS;Windows | React.js | React.js | NaN | NaN | PHPStorm | Windows | I do not use containers | NaN | Useful for decentralized currency (i.e., Bitcoin) | No | Yes | No | YouTube | NaN | NaN | 2014 | Daily or almost daily | Find answers to specific questions | 3-5 times per week | NaN | NaN | Yes | Less than once per month or monthly | Yes | No, and I don't know what those are | Neutral | A lot more welcome now than last year | NaN | 42.0 | Man | No | Straight / Heterosexual | White or of European descent | Yes | Appropriate in length | Neither easy nor difficult |
|---|
| 7 | 8 | I code primarily as a hobby | Yes | Less than once per year | OSS is, on average, of HIGHER quality than pro... | Not employed, but looking for work | India | NaN | Bachelor’s degree (BA, BS, B.Eng., etc.) | Computer science, computer engineering, or sof... | Taught yourself a new language, framework, or ... | NaN | Developer, back-end;Engineer, site reliability | 8 | 16 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | Bash/Shell/PowerShell;C;C++;HTML/CSS;Java;Java... | Bash/Shell/PowerShell;C;C++;Elixir;Erlang;Go;P... | Cassandra;Elasticsearch;MongoDB;MySQL;Oracle;R... | Cassandra;DynamoDB;Elasticsearch;Firebase;Mong... | AWS;Docker;Heroku;Linux;MacOS;Slack | Android;Arduino;AWS;Docker;Google Cloud Platfo... | Express;Flask;React.js;Spring | Django;Express;Flask;React.js;Vue.js | Hadoop;Node.js;Pandas | Ansible;Apache Spark;Chef;Hadoop;Node.js;Panda... | Atom;IntelliJ;IPython / Jupyter;PyCharm;Visual... | Linux-based | Development;Testing;Production;Outside of work... | NaN | Useful across many domains and could change ma... | Yes | SIGH | Yes | YouTube | In real life (in person) | Handle | 2012 | A few times per week | Find answers to specific questions;Learn how t... | Less than once per week | Stack Overflow was slightly faster | 11-30 minutes | Yes | Less than once per month or monthly | Yes | No, and I don't know what those are | Yes, definitely | A lot more welcome now than last year | Tech articles written by other developers;Indu... | 24.0 | Man | No | Straight / Heterosexual | NaN | NaN | Appropriate in length | Neither easy nor difficult |
|---|
| 8 | 9 | I am a developer by profession | Yes | Once a month or more often | The quality of OSS and closed source software ... | Employed full-time | New Zealand | No | Some college/university study without earning ... | Computer science, computer engineering, or sof... | Taken an online course in programming or softw... | 10 to 19 employees | Database administrator;Developer, back-end;Dev... | 12 | 11 | 4 | Slightly satisfied | Slightly satisfied | Somewhat confident | No | Not sure | I’m not actively looking, but I am open to new... | Less than a year ago | Write any code;Interview with people in peer r... | Yes | Financial performance or funding status of the... | I was preparing for a job search | NZD | New Zealand dollar | 138000.0 | Yearly | 95179.0 | 32.0 | There is a schedule and/or spec (made by me or... | Being tasked with non-development work;Inadequ... | Less than once per month / Never | Office | A little above average | Yes, because I see value in code review | 12.0 | Yes, it's not part of our process but the deve... | Not sure | I have some influence | Bash/Shell/PowerShell;C#;HTML/CSS;JavaScript;P... | Bash/Shell/PowerShell;C;HTML/CSS;JavaScript;Ru... | DynamoDB;PostgreSQL;SQLite | PostgreSQL;Redis;SQLite | AWS;Docker;Heroku;Linux;MacOS;Slack | AWS;Docker;Heroku;Linux;MacOS;Slack;Other(s): | Express;Ruby on Rails;Other(s): | Express;Ruby on Rails;Other(s): | Node.js;Unity 3D | Node.js | Vim | MacOS | Development;Testing;Production | Not at all | An irresponsible use of resources | No | SIGH | Yes | Twitter | In real life (in person) | Username | 2013 | Daily or almost daily | Find answers to specific questions;Contribute ... | 3-5 times per week | They were about the same | NaN | Yes | Less than once per month or monthly | No, I knew that Stack Overflow had a job board... | No, and I don't know what those are | Yes, somewhat | Just as welcome now as I felt last year | NaN | 23.0 | Man | No | Bisexual | White or of European descent | No | Appropriate in length | Neither easy nor difficult |
|---|
| 9 | 10 | I am a developer by profession | Yes | Once a month or more often | OSS is, on average, of HIGHER quality than pro... | Employed full-time | India | No | Master’s degree (MA, MS, M.Eng., MBA, etc.) | NaN | NaN | 10,000 or more employees | Data or business analyst;Data scientist or mac... | 12 | 20 | 10 | Slightly dissatisfied | Slightly dissatisfied | Somewhat confident | Yes | Yes | I’m not actively looking, but I am open to new... | 3-4 years ago | NaN | No | Languages, frameworks, and other technologies ... | NaN | INR | Indian rupee | 950000.0 | Yearly | 13293.0 | 70.0 | There's no schedule or spec; I work on what se... | NaN | A few days each month | Home | Far above average | Yes, because I see value in code review | 4.0 | Yes, it's part of our process | NaN | NaN | C#;Go;JavaScript;Python;R;SQL | C#;Go;JavaScript;Kotlin;Python;R;SQL | Elasticsearch;MongoDB;Microsoft SQL Server;MyS... | Elasticsearch;MongoDB;Microsoft SQL Server | Linux;Windows | Android;Linux;Raspberry Pi;Windows | Angular/Angular.js;ASP.NET;Django;Express;Flas... | Angular/Angular.js;ASP.NET;Django;Express;Flas... | .NET;Node.js;Pandas;Torch/PyTorch | .NET;Node.js;TensorFlow;Torch/PyTorch | Android Studio;Eclipse;IPython / Jupyter;Notep... | Windows | NaN | Not at all | Useful for immutable record keeping outside of... | No | Yes | Yes | YouTube | Neither | Screen Name | NaN | Multiple times per day | Find answers to specific questions;Get a sense... | 3-5 times per week | They were about the same | NaN | Yes | A few times per month or weekly | Yes | No, and I don't know what those are | Yes, somewhat | Somewhat less welcome now than last year | Tech articles written by other developers;Tech... | NaN | NaN | NaN | NaN | NaN | Yes | Too long | Difficult |
|---|
查看后十条
df.tail(10)
| Respondent | MainBranch | Hobbyist | OpenSourcer | OpenSource | Employment | Country | Student | EdLevel | UndergradMajor | EduOther | OrgSize | DevType | YearsCode | Age1stCode | YearsCodePro | CareerSat | JobSat | MgrIdiot | MgrMoney | MgrWant | JobSeek | LastHireDate | LastInt | FizzBuzz | JobFactors | ResumeUpdate | CurrencySymbol | CurrencyDesc | CompTotal | CompFreq | ConvertedComp | WorkWeekHrs | WorkPlan | WorkChallenge | WorkRemote | WorkLoc | ImpSyn | CodeRev | CodeRevHrs | UnitTests | PurchaseHow | PurchaseWhat | LanguageWorkedWith | LanguageDesireNextYear | DatabaseWorkedWith | DatabaseDesireNextYear | PlatformWorkedWith | PlatformDesireNextYear | WebFrameWorkedWith | WebFrameDesireNextYear | MiscTechWorkedWith | MiscTechDesireNextYear | DevEnviron | OpSys | Containers | BlockchainOrg | BlockchainIs | BetterLife | ITperson | OffOn | SocialMedia | Extraversion | ScreenName | SOVisit1st | SOVisitFreq | SOVisitTo | SOFindAnswer | SOTimeSaved | SOHowMuchTime | SOAccount | SOPartFreq | SOJobs | EntTeams | SOComm | WelcomeChange | SONewContent | Age | Gender | Trans | Sexuality | Ethnicity | Dependents | SurveyLength | SurveyEase |
|---|
| 88873 | 88062 | NaN | No | Never | OSS is, on average, of LOWER quality than prop... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
|---|
| 88874 | 88076 | NaN | No | Never | OSS is, on average, of HIGHER quality than pro... | Employed full-time | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
|---|
| 88875 | 88182 | NaN | Yes | Once a month or more often | OSS is, on average, of HIGHER quality than pro... | Employed part-time | Pakistan | NaN | Secondary school (e.g. American high school, G... | NaN | Taken an online course in programming or softw... | 10 to 19 employees | Academic researcher | 1 | Younger than 5 years | Less than 1 year | NaN | NaN | Very confident | Not sure | Yes | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | HTML/CSS;Java;JavaScript | NaN | NaN | NaN | Google Cloud Platform | NaN | Other(s): | NaN | Other(s): | NaN | Android Studio | Windows | Development | NaN | Useful across many domains and could change ma... | Yes | Also Yes | What? | Twitter | Neither | Username | NaN | I have never visited Stack Overflow (before to... | Get a sense of belonging to the developer comm... | Less than once per week | The other resource was slightly faster | 60+ minutes | NaN | NaN | No, I didn't know that Stack Overflow had a jo... | No, and I don't know what those are | Neutral | Not applicable - I did not use Stack Overflow ... | Courses on technologies you're interested in | NaN | Man | No | Straight / Heterosexual | NaN | Yes | Too short | Neither easy nor difficult |
|---|
| 88876 | 88212 | NaN | No | Less than once per year | OSS is, on average, of HIGHER quality than pro... | Employed full-time | Spain | No | Secondary school (e.g. American high school, G... | NaN | Taught yourself a new language, framework, or ... | 10 to 19 employees | Designer;Developer, front-end;Developer, full-... | 18 | 7 | 15 | NaN | NaN | Somewhat confident | Yes | I am already a manager | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | HTML/CSS;JavaScript;Python | JavaScript | MySQL;PostgreSQL | PostgreSQL | NaN | Arduino | Django;React.js | Django;React.js | NaN | NaN | Atom;Visual Studio Code | MacOS | I do not use containers | Non-currency applications of blockchain | Useful for immutable record keeping outside of... | No | SIGH | No | WhatsApp | In real life (in person) | Username | 2008 | A few times per week | Find answers to specific questions | 6-10 times per week | Stack Overflow was slightly faster | 0-10 minutes | Yes | I have never participated in Q&A on Stack Over... | No, I didn't know that Stack Overflow had a jo... | No, and I don't know what those are | No, not at all | NaN | Tech articles written by other developers;Indu... | 40.0 | Man | No | Straight / Heterosexual | White or of European descent | No | Appropriate in length | Easy |
|---|
| 88877 | 88282 | NaN | Yes | Once a month or more often | The quality of OSS and closed source software ... | Not employed, but looking for work | United States | No | Some college/university study without earning ... | Computer science, computer engineering, or sof... | Taught yourself a new language, framework, or ... | NaN | Developer, back-end;Developer, desktop or ente... | 38 | 10 | 38 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | Bash/Shell/PowerShell;Go;HTML/CSS;JavaScript;W... | Bash/Shell/PowerShell;C;Go;HTML/CSS;JavaScript... | NaN | NaN | Linux | Linux;Raspberry Pi | React.js | Vue.js | Node.js | Ansible | Vim | Linux-based | I do not use containers | NaN | An irresponsible use of resources | No | NaN | Yes | I don't use social media | In real life (in person) | Username | I don't remember | A few times per month or weekly | Find answers to specific questions | 1-2 times per week | They were about the same | NaN | Yes | I have never participated in Q&A on Stack Over... | Yes | No, and I don't know what those are | No, not really | Just as welcome now as I felt last year | NaN | NaN | Man | No | Straight / Heterosexual | NaN | No | Too short | Neither easy nor difficult |
|---|
| 88878 | 88377 | NaN | Yes | Less than once a month but more than once per ... | The quality of OSS and closed source software ... | Not employed, and not looking for work | Canada | No | Primary/elementary school | NaN | Taught yourself a new language, framework, or ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | HTML/CSS;JavaScript;Other(s): | C++;HTML/CSS;JavaScript;SQL;WebAssembly;Other(s): | Firebase;SQLite | Firebase;MySQL;SQLite | Linux | Google Cloud Platform;Linux | jQuery | jQuery;Vue.js | Node.js | React Native;Unity 3D;Unreal Engine | Atom;Visual Studio;Visual Studio Code | Windows | I do not use containers | NaN | Useful across many domains and could change ma... | Yes | Yes | What? | YouTube | NaN | Username | I don't remember | A few times per week | Find answers to specific questions;Learn how t... | 3-5 times per week | Stack Overflow was slightly faster | 11-30 minutes | Yes | I have never participated in Q&A on Stack Over... | No, I knew that Stack Overflow had a job board... | No, I've heard of them, but I am not part of a... | No, not at all | NaN | Tech articles written by other developers;Tech... | NaN | Man | No | NaN | NaN | No | Appropriate in length | Easy |
|---|
| 88879 | 88601 | NaN | No | Never | The quality of OSS and closed source software ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
|---|
| 88880 | 88802 | NaN | No | Never | NaN | Employed full-time | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
|---|
| 88881 | 88816 | NaN | No | Never | OSS is, on average, of HIGHER quality than pro... | Independent contractor, freelancer, or self-em... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
|---|
| 88882 | 88863 | NaN | Yes | Less than once per year | OSS is, on average, of HIGHER quality than pro... | Not employed, and not looking for work | Spain | Yes, full-time | Professional degree (JD, MD, etc.) | Computer science, computer engineering, or sof... | Taken an online course in programming or softw... | NaN | NaN | 8 | 11 | 3 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | Bash/Shell/PowerShell;HTML/CSS;Java;JavaScript... | C;C++;C#;HTML/CSS;Java;Objective-C;SQL;Swift | DynamoDB;MariaDB;Microsoft SQL Server;MySQL | MariaDB;MySQL;Oracle;SQLite | iOS;Linux;MacOS;WordPress | Android;AWS;Google Cloud Platform;IBM Cloud or... | Django;jQuery;React.js | Django | Unity 3D;Unreal Engine | NaN | Android Studio;Atom;Eclipse;NetBeans;Notepad++... | Linux-based | Production | NaN | Useful for decentralized currency (i.e., Bitcoin) | Yes | Also Yes | Yes | WhatsApp | In real life (in person) | NaN | 2012 | Daily or almost daily | Find answers to specific questions;Learn how t... | 6-10 times per week | Stack Overflow was much faster | 11-30 minutes | Yes | A few times per month or weekly | Yes | No, I've heard of them, but I am not part of a... | Yes, somewhat | Somewhat less welcome now than last year | Tech articles written by other developers;Indu... | 18.0 | Man | No | Straight / Heterosexual | Hispanic or Latino/Latina;White or of European... | No | Appropriate in length | Easy |
|---|
df.shape
(88883, 85)
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 88883 entries, 0 to 88882
Data columns (total 85 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Respondent 88883 non-null int64
1 MainBranch 88331 non-null object
2 Hobbyist 88883 non-null object
3 OpenSourcer 88883 non-null object
4 OpenSource 86842 non-null object
5 Employment 87181 non-null object
6 Country 88751 non-null object
7 Student 87014 non-null object
8 EdLevel 86390 non-null object
9 UndergradMajor 75614 non-null object
10 EduOther 84260 non-null object
11 OrgSize 71791 non-null object
12 DevType 81335 non-null object
13 YearsCode 87938 non-null object
14 Age1stCode 87634 non-null object
15 YearsCodePro 74331 non-null object
16 CareerSat 72847 non-null object
17 JobSat 70988 non-null object
18 MgrIdiot 61159 non-null object
19 MgrMoney 61157 non-null object
20 MgrWant 61232 non-null object
21 JobSeek 80555 non-null object
22 LastHireDate 79854 non-null object
23 LastInt 67155 non-null object
24 FizzBuzz 71344 non-null object
25 JobFactors 79371 non-null object
26 ResumeUpdate 77877 non-null object
27 CurrencySymbol 71392 non-null object
28 CurrencyDesc 71392 non-null object
29 CompTotal 55945 non-null float64
30 CompFreq 63268 non-null object
31 ConvertedComp 55823 non-null float64
32 WorkWeekHrs 64503 non-null float64
33 WorkPlan 68914 non-null object
34 WorkChallenge 68141 non-null object
35 WorkRemote 70284 non-null object
36 WorkLoc 70055 non-null object
37 ImpSyn 71779 non-null object
38 CodeRev 70390 non-null object
39 CodeRevHrs 49790 non-null float64
40 UnitTests 62668 non-null object
41 PurchaseHow 61108 non-null object
42 PurchaseWhat 62029 non-null object
43 LanguageWorkedWith 87569 non-null object
44 LanguageDesireNextYear 84088 non-null object
45 DatabaseWorkedWith 76026 non-null object
46 DatabaseDesireNextYear 69147 non-null object
47 PlatformWorkedWith 80714 non-null object
48 PlatformDesireNextYear 77443 non-null object
49 WebFrameWorkedWith 65022 non-null object
50 WebFrameDesireNextYear 62944 non-null object
51 MiscTechWorkedWith 59586 non-null object
52 MiscTechDesireNextYear 64511 non-null object
53 DevEnviron 87317 non-null object
54 OpSys 87851 non-null object
55 Containers 85366 non-null object
56 BlockchainOrg 48175 non-null object
57 BlockchainIs 60165 non-null object
58 BetterLife 86269 non-null object
59 ITperson 87141 non-null object
60 OffOn 86663 non-null object
61 SocialMedia 84437 non-null object
62 Extraversion 87305 non-null object
63 ScreenName 80486 non-null object
64 SOVisit1st 83877 non-null object
65 SOVisitFreq 88263 non-null object
66 SOVisitTo 88086 non-null object
67 SOFindAnswer 87816 non-null object
68 SOTimeSaved 86344 non-null object
69 SOHowMuchTime 68378 non-null object
70 SOAccount 87828 non-null object
71 SOPartFreq 74692 non-null object
72 SOJobs 88066 non-null object
73 EntTeams 87841 non-null object
74 SOComm 88131 non-null object
75 WelcomeChange 85855 non-null object
76 SONewContent 69560 non-null object
77 Age 79210 non-null float64
78 Gender 85406 non-null object
79 Trans 83607 non-null object
80 Sexuality 76147 non-null object
81 Ethnicity 76668 non-null object
82 Dependents 83059 non-null object
83 SurveyLength 86984 non-null object
84 SurveyEase 87081 non-null object
dtypes: float64(5), int64(1), object(79)
memory usage: 57.6+ MB
显示85列显示85行
pd.set_option('display.max_columns',85)
pd.set_option('display.max_rows',85)
schema_df = pd.read_csv('data/survey_results_schema.csv')
schema_df
| Column | QuestionText |
|---|
| 0 | Respondent | Randomized respondent ID number (not in order ... |
|---|
| 1 | MainBranch | Which of the following options best describes ... |
|---|
| 2 | Hobbyist | Do you code as a hobby? |
|---|
| 3 | OpenSourcer | How often do you contribute to open source? |
|---|
| 4 | OpenSource | How do you feel about the quality of open sour... |
|---|
| 5 | Employment | Which of the following best describes your cur... |
|---|
| 6 | Country | In which country do you currently reside? |
|---|
| 7 | Student | Are you currently enrolled in a formal, degree... |
|---|
| 8 | EdLevel | Which of the following best describes the high... |
|---|
| 9 | UndergradMajor | What was your main or most important field of ... |
|---|
| 10 | EduOther | Which of the following types of non-degree edu... |
|---|
| 11 | OrgSize | Approximately how many people are employed by ... |
|---|
| 12 | DevType | Which of the following describe you? Please se... |
|---|
| 13 | YearsCode | Including any education, how many years have y... |
|---|
| 14 | Age1stCode | At what age did you write your first line of c... |
|---|
| 15 | YearsCodePro | How many years have you coded professionally (... |
|---|
| 16 | CareerSat | Overall, how satisfied are you with your caree... |
|---|
| 17 | JobSat | How satisfied are you with your current job? (... |
|---|
| 18 | MgrIdiot | How confident are you that your manager knows ... |
|---|
| 19 | MgrMoney | Do you believe that you need to be a manager t... |
|---|
| 20 | MgrWant | Do you want to become a manager yourself in th... |
|---|
| 21 | JobSeek | Which of the following best describes your cur... |
|---|
| 22 | LastHireDate | When was the last time that you took a job wit... |
|---|
| 23 | LastInt | In your most recent successful job interview (... |
|---|
| 24 | FizzBuzz | Have you ever been asked to solve FizzBuzz in ... |
|---|
| 25 | JobFactors | Imagine that you are deciding between two job ... |
|---|
| 26 | ResumeUpdate | Think back to the last time you updated your r... |
|---|
| 27 | CurrencySymbol | Which currency do you use day-to-day? If your ... |
|---|
| 28 | CurrencyDesc | Which currency do you use day-to-day? If your ... |
|---|
| 29 | CompTotal | What is your current total compensation (salar... |
|---|
| 30 | CompFreq | Is that compensation weekly, monthly, or yearly? |
|---|
| 31 | ConvertedComp | Salary converted to annual USD salaries using ... |
|---|
| 32 | WorkWeekHrs | On average, how many hours per week do you work? |
|---|
| 33 | WorkPlan | How structured or planned is your work? |
|---|
| 34 | WorkChallenge | Of these options, what are your greatest chall... |
|---|
| 35 | WorkRemote | How often do you work remotely? |
|---|
| 36 | WorkLoc | Where would you prefer to work? |
|---|
| 37 | ImpSyn | For the specific work you do, and the years of... |
|---|
| 38 | CodeRev | Do you review code as part of your work? |
|---|
| 39 | CodeRevHrs | On average, how many hours per week do you spe... |
|---|
| 40 | UnitTests | Does your company regularly employ unit tests ... |
|---|
| 41 | PurchaseHow | How does your company make decisions about pur... |
|---|
| 42 | PurchaseWhat | What level of influence do you, personally, ha... |
|---|
| 43 | LanguageWorkedWith | Which of the following programming, scripting,... |
|---|
| 44 | LanguageDesireNextYear | Which of the following programming, scripting,... |
|---|
| 45 | DatabaseWorkedWith | Which of the following database environments h... |
|---|
| 46 | DatabaseDesireNextYear | Which of the following database environments h... |
|---|
| 47 | PlatformWorkedWith | Which of the following platforms have you done... |
|---|
| 48 | PlatformDesireNextYear | Which of the following platforms have you done... |
|---|
| 49 | WebFrameWorkedWith | Which of the following web frameworks have you... |
|---|
| 50 | WebFrameDesireNextYear | Which of the following web frameworks have you... |
|---|
| 51 | MiscTechWorkedWith | Which of the following other frameworks, libra... |
|---|
| 52 | MiscTechDesireNextYear | Which of the following other frameworks, libra... |
|---|
| 53 | DevEnviron | Which development environment(s) do you use re... |
|---|
| 54 | OpSys | What is the primary operating system in which ... |
|---|
| 55 | Containers | How do you use containers (Docker, Open Contai... |
|---|
| 56 | BlockchainOrg | How is your organization thinking about or imp... |
|---|
| 57 | BlockchainIs | Blockchain / cryptocurrency technology is prim... |
|---|
| 58 | BetterLife | Do you think people born today will have a bet... |
|---|
| 59 | ITperson | Are you the "IT support person" for your family? |
|---|
| 60 | OffOn | Have you tried turning it off and on again? |
|---|
| 61 | SocialMedia | What social media site do you use the most? |
|---|
| 62 | Extraversion | Do you prefer online chat or IRL conversations? |
|---|
| 63 | ScreenName | What do you call it? |
|---|
| 64 | SOVisit1st | To the best of your memory, when did you first... |
|---|
| 65 | SOVisitFreq | How frequently would you say you visit Stack O... |
|---|
| 66 | SOVisitTo | I visit Stack Overflow to... (check all that a... |
|---|
| 67 | SOFindAnswer | On average, how many times a week do you find ... |
|---|
| 68 | SOTimeSaved | Think back to the last time you solved a codin... |
|---|
| 69 | SOHowMuchTime | About how much time did you save? If you're no... |
|---|
| 70 | SOAccount | Do you have a Stack Overflow account? |
|---|
| 71 | SOPartFreq | How frequently would you say you participate i... |
|---|
| 72 | SOJobs | Have you ever used or visited Stack Overflow J... |
|---|
| 73 | EntTeams | Have you ever used Stack Overflow for Enterpri... |
|---|
| 74 | SOComm | Do you consider yourself a member of the Stack... |
|---|
| 75 | WelcomeChange | Compared to last year, how welcome do you feel... |
|---|
| 76 | SONewContent | Would you like to see any of the following on ... |
|---|
| 77 | Age | What is your age (in years)? If you prefer not... |
|---|
| 78 | Gender | Which of the following do you currently identi... |
|---|
| 79 | Trans | Do you identify as transgender? |
|---|
| 80 | Sexuality | Which of the following do you currently identi... |
|---|
| 81 | Ethnicity | Which of the following do you identify as? Ple... |
|---|
| 82 | Dependents | Do you have any dependents (e.g., children, el... |
|---|
| 83 | SurveyLength | How do you feel about the length of the survey... |
|---|
| 84 | SurveyEase | How easy or difficult was this survey to compl... |
|---|
DataFrame
字典转化为DataFrame
people = {
"first": ["Corey", 'Jane', 'John'],
"last": ["Schafer", 'Doe', 'Doe'],
"email": ["CoreyMSchafer@gmail", 'JaneDoe@email', 'JohnDoe@email']
}
people['email']
['CoreyMSchafer@gmail', 'JaneDoe@email', 'JohnDoe@email']
import pandas as pd
df = pd.DataFrame(people)
Dataframe的访问
df
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
df['email']
0 CoreyMSchafer@gmail
1 JaneDoe@email
2 JohnDoe@email
Name: email, dtype: object
type(df['email'])
pandas.core.series.Series
df.email
0 CoreyMSchafer@gmail
1 JaneDoe@email
2 JohnDoe@email
Name: email, dtype: object
df[['last','email']]
| last | email |
|---|
| 0 | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Doe | JaneDoe@email |
|---|
| 2 | Doe | JohnDoe@email |
|---|
单列返回的是series多列返回的是dataframe
df.columns
Index(['first', 'last', 'email'], dtype='object')
df.iloc[0]
first Corey
last Schafer
email CoreyMSchafer@gmail
Name: 0, dtype: object
df
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
df.iloc[[0,1],2]
0 CoreyMSchafer@gmail
1 JaneDoe@email
Name: email, dtype: object
df.loc[[0,1],['email','last']]
| email | last |
|---|
| 0 | CoreyMSchafer@gmail | Schafer |
|---|
| 1 | JaneDoe@email | Doe |
|---|
df = pd.read_csv('data/survey_results_public.csv')
schema_df = pd.read_csv('data/survey_results_schema.csv')
pd.set_option('display.max_columns', 85)
pd.set_option('display.max_rows', 85)
df.columns
Index(['Respondent', 'MainBranch', 'Hobbyist', 'OpenSourcer', 'OpenSource',
'Employment', 'Country', 'Student', 'EdLevel', 'UndergradMajor',
'EduOther', 'OrgSize', 'DevType', 'YearsCode', 'Age1stCode',
'YearsCodePro', 'CareerSat', 'JobSat', 'MgrIdiot', 'MgrMoney',
'MgrWant', 'JobSeek', 'LastHireDate', 'LastInt', 'FizzBuzz',
'JobFactors', 'ResumeUpdate', 'CurrencySymbol', 'CurrencyDesc',
'CompTotal', 'CompFreq', 'ConvertedComp', 'WorkWeekHrs', 'WorkPlan',
'WorkChallenge', 'WorkRemote', 'WorkLoc', 'ImpSyn', 'CodeRev',
'CodeRevHrs', 'UnitTests', 'PurchaseHow', 'PurchaseWhat',
'LanguageWorkedWith', 'LanguageDesireNextYear', 'DatabaseWorkedWith',
'DatabaseDesireNextYear', 'PlatformWorkedWith',
'PlatformDesireNextYear', 'WebFrameWorkedWith',
'WebFrameDesireNextYear', 'MiscTechWorkedWith',
'MiscTechDesireNextYear', 'DevEnviron', 'OpSys', 'Containers',
'BlockchainOrg', 'BlockchainIs', 'BetterLife', 'ITperson', 'OffOn',
'SocialMedia', 'Extraversion', 'ScreenName', 'SOVisit1st',
'SOVisitFreq', 'SOVisitTo', 'SOFindAnswer', 'SOTimeSaved',
'SOHowMuchTime', 'SOAccount', 'SOPartFreq', 'SOJobs', 'EntTeams',
'SOComm', 'WelcomeChange', 'SONewContent', 'Age', 'Gender', 'Trans',
'Sexuality', 'Ethnicity', 'Dependents', 'SurveyLength', 'SurveyEase'],
dtype='object')
df['Hobbyist']
0 Yes
1 No
2 Yes
3 No
4 Yes
...
88878 Yes
88879 No
88880 No
88881 No
88882 Yes
Name: Hobbyist, Length: 88883, dtype: object
df['Hobbyist'].value_counts()
Yes 71257
No 17626
Name: Hobbyist, dtype: int64
df.loc[0]
Respondent 1
MainBranch I am a student who is learning to code
Hobbyist Yes
OpenSourcer Never
OpenSource The quality of OSS and closed source software ...
Employment Not employed, and not looking for work
Country United Kingdom
Student No
EdLevel Primary/elementary school
UndergradMajor NaN
EduOther Taught yourself a new language, framework, or ...
OrgSize NaN
DevType NaN
YearsCode 4
Age1stCode 10
YearsCodePro NaN
CareerSat NaN
JobSat NaN
MgrIdiot NaN
MgrMoney NaN
MgrWant NaN
JobSeek NaN
LastHireDate NaN
LastInt NaN
FizzBuzz NaN
JobFactors NaN
ResumeUpdate NaN
CurrencySymbol NaN
CurrencyDesc NaN
CompTotal NaN
CompFreq NaN
ConvertedComp NaN
WorkWeekHrs NaN
WorkPlan NaN
WorkChallenge NaN
WorkRemote NaN
WorkLoc NaN
ImpSyn NaN
CodeRev NaN
CodeRevHrs NaN
UnitTests NaN
PurchaseHow NaN
PurchaseWhat NaN
LanguageWorkedWith HTML/CSS;Java;JavaScript;Python
LanguageDesireNextYear C;C++;C#;Go;HTML/CSS;Java;JavaScript;Python;SQL
DatabaseWorkedWith SQLite
DatabaseDesireNextYear MySQL
PlatformWorkedWith MacOS;Windows
PlatformDesireNextYear Android;Arduino;Windows
WebFrameWorkedWith Django;Flask
WebFrameDesireNextYear Flask;jQuery
MiscTechWorkedWith Node.js
MiscTechDesireNextYear Node.js
DevEnviron IntelliJ;Notepad++;PyCharm
OpSys Windows
Containers I do not use containers
BlockchainOrg NaN
BlockchainIs NaN
BetterLife Yes
ITperson Fortunately, someone else has that title
OffOn Yes
SocialMedia Twitter
Extraversion Online
ScreenName Username
SOVisit1st 2017
SOVisitFreq A few times per month or weekly
SOVisitTo Find answers to specific questions;Learn how t...
SOFindAnswer 3-5 times per week
SOTimeSaved Stack Overflow was much faster
SOHowMuchTime 31-60 minutes
SOAccount No
SOPartFreq NaN
SOJobs No, I didn't know that Stack Overflow had a jo...
EntTeams No, and I don't know what those are
SOComm Neutral
WelcomeChange Just as welcome now as I felt last year
SONewContent Tech articles written by other developers;Indu...
Age 14.0
Gender Man
Trans No
Sexuality Straight / Heterosexual
Ethnicity NaN
Dependents No
SurveyLength Appropriate in length
SurveyEase Neither easy nor difficult
Name: 0, dtype: object
df.loc[0:2,'Hobbyist': 'Employment']
| Hobbyist | OpenSourcer | OpenSource | Employment |
|---|
| 0 | Yes | Never | The quality of OSS and closed source software ... | Not employed, and not looking for work |
|---|
| 1 | No | Less than once per year | The quality of OSS and closed source software ... | Not employed, but looking for work |
|---|
| 2 | Yes | Never | The quality of OSS and closed source software ... | Employed full-time |
|---|
设置索引、使用索引
设置索引
people = {
"first": ["Corey", 'Jane', 'John'],
"last": ["Schafer", 'Doe', 'Doe'],
"email": ["CoreyMSchafer@gmail", 'JaneDoe@email', 'JohnDoe@email']
}
import pandas as pd
df = pd.DataFrame(people)
df
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
df.set_index('email')
| first | last |
|---|
| email | | |
|---|
| CoreyMSchafer@gmail | Corey | Schafer |
|---|
| JaneDoe@email | Jane | Doe |
|---|
| JohnDoe@email | John | Doe |
|---|
df
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
设置索引并没有对在df基础上设置,df仍然没变,仍使用默认索引值,所以需要添加inplace=True
df.set_index('email',inplace=True)
df
| first | last |
|---|
| email | | |
|---|
| CoreyMSchafer@gmail | Corey | Schafer |
|---|
| JaneDoe@email | Jane | Doe |
|---|
| JohnDoe@email | John | Doe |
|---|
df.index
Index(['CoreyMSchafer@gmail', 'JaneDoe@email', 'JohnDoe@email'], dtype='object', name='email')
df.loc['CoreyMSchafer@gmail','last']
'Schafer'
df.reset_index(inplace=True)
df
| index | email | first | last |
|---|
| 0 | 0 | CoreyMSchafer@gmail | Corey | Schafer |
|---|
| 1 | 1 | JaneDoe@email | Jane | Doe |
|---|
| 2 | 2 | JohnDoe@email | John | Doe |
|---|
df = pd.read_csv('data/survey_results_public.csv',index_col='Respondent')
pd.set_option('display.max_columns', 85)
pd.set_option('display.max_rows', 85)
df.head()
| MainBranch | Hobbyist | OpenSourcer | OpenSource | Employment | Country | Student | EdLevel | UndergradMajor | EduOther | OrgSize | DevType | YearsCode | Age1stCode | YearsCodePro | CareerSat | JobSat | MgrIdiot | MgrMoney | MgrWant | JobSeek | LastHireDate | LastInt | FizzBuzz | JobFactors | ResumeUpdate | CurrencySymbol | CurrencyDesc | CompTotal | CompFreq | ConvertedComp | WorkWeekHrs | WorkPlan | WorkChallenge | WorkRemote | WorkLoc | ImpSyn | CodeRev | CodeRevHrs | UnitTests | PurchaseHow | PurchaseWhat | LanguageWorkedWith | LanguageDesireNextYear | DatabaseWorkedWith | DatabaseDesireNextYear | PlatformWorkedWith | PlatformDesireNextYear | WebFrameWorkedWith | WebFrameDesireNextYear | MiscTechWorkedWith | MiscTechDesireNextYear | DevEnviron | OpSys | Containers | BlockchainOrg | BlockchainIs | BetterLife | ITperson | OffOn | SocialMedia | Extraversion | ScreenName | SOVisit1st | SOVisitFreq | SOVisitTo | SOFindAnswer | SOTimeSaved | SOHowMuchTime | SOAccount | SOPartFreq | SOJobs | EntTeams | SOComm | WelcomeChange | SONewContent | Age | Gender | Trans | Sexuality | Ethnicity | Dependents | SurveyLength | SurveyEase |
|---|
| Respondent | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|---|
| 1 | I am a student who is learning to code | Yes | Never | The quality of OSS and closed source software ... | Not employed, and not looking for work | United Kingdom | No | Primary/elementary school | NaN | Taught yourself a new language, framework, or ... | NaN | NaN | 4 | 10 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | HTML/CSS;Java;JavaScript;Python | C;C++;C#;Go;HTML/CSS;Java;JavaScript;Python;SQL | SQLite | MySQL | MacOS;Windows | Android;Arduino;Windows | Django;Flask | Flask;jQuery | Node.js | Node.js | IntelliJ;Notepad++;PyCharm | Windows | I do not use containers | NaN | NaN | Yes | Fortunately, someone else has that title | Yes | Twitter | Online | Username | 2017 | A few times per month or weekly | Find answers to specific questions;Learn how t... | 3-5 times per week | Stack Overflow was much faster | 31-60 minutes | No | NaN | No, I didn't know that Stack Overflow had a jo... | No, and I don't know what those are | Neutral | Just as welcome now as I felt last year | Tech articles written by other developers;Indu... | 14.0 | Man | No | Straight / Heterosexual | NaN | No | Appropriate in length | Neither easy nor difficult |
|---|
| 2 | I am a student who is learning to code | No | Less than once per year | The quality of OSS and closed source software ... | Not employed, but looking for work | Bosnia and Herzegovina | Yes, full-time | Secondary school (e.g. American high school, G... | NaN | Taken an online course in programming or softw... | NaN | Developer, desktop or enterprise applications;... | NaN | 17 | NaN | NaN | NaN | NaN | NaN | NaN | I am actively looking for a job | I've never had a job | NaN | NaN | Financial performance or funding status of the... | Something else changed (education, award, medi... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | C++;HTML/CSS;Python | C++;HTML/CSS;JavaScript;SQL | NaN | MySQL | Windows | Windows | Django | Django | NaN | NaN | Atom;PyCharm | Windows | I do not use containers | NaN | Useful across many domains and could change ma... | Yes | Yes | Yes | Instagram | Online | Username | 2017 | Daily or almost daily | Find answers to specific questions;Learn how t... | 3-5 times per week | Stack Overflow was much faster | 11-30 minutes | Yes | A few times per month or weekly | No, I knew that Stack Overflow had a job board... | No, and I don't know what those are | Yes, somewhat | Just as welcome now as I felt last year | Tech articles written by other developers;Indu... | 19.0 | Man | No | Straight / Heterosexual | NaN | No | Appropriate in length | Neither easy nor difficult |
|---|
| 3 | I am not primarily a developer, but I write co... | Yes | Never | The quality of OSS and closed source software ... | Employed full-time | Thailand | No | Bachelor’s degree (BA, BS, B.Eng., etc.) | Web development or web design | Taught yourself a new language, framework, or ... | 100 to 499 employees | Designer;Developer, back-end;Developer, front-... | 3 | 22 | 1 | Slightly satisfied | Slightly satisfied | Not at all confident | Not sure | Not sure | I’m not actively looking, but I am open to new... | 1-2 years ago | Interview with people in peer roles | No | Languages, frameworks, and other technologies ... | I was preparing for a job search | THB | Thai baht | 23000.0 | Monthly | 8820.0 | 40.0 | There's no schedule or spec; I work on what se... | Distracting work environment;Inadequate access... | Less than once per month / Never | Home | Average | No | NaN | No, but I think we should | Not sure | I have little or no influence | HTML/CSS | Elixir;HTML/CSS | PostgreSQL | PostgreSQL | NaN | NaN | NaN | Other(s): | NaN | NaN | Vim;Visual Studio Code | Linux-based | I do not use containers | NaN | NaN | Yes | Yes | Yes | Reddit | In real life (in person) | Username | 2011 | A few times per week | Find answers to specific questions;Learn how t... | 6-10 times per week | They were about the same | NaN | Yes | Less than once per month or monthly | Yes | No, I've heard of them, but I am not part of a... | Neutral | Just as welcome now as I felt last year | Tech meetups or events in your area;Courses on... | 28.0 | Man | No | Straight / Heterosexual | NaN | Yes | Appropriate in length | Neither easy nor difficult |
|---|
| 4 | I am a developer by profession | No | Never | The quality of OSS and closed source software ... | Employed full-time | United States | No | Bachelor’s degree (BA, BS, B.Eng., etc.) | Computer science, computer engineering, or sof... | Taken an online course in programming or softw... | 100 to 499 employees | Developer, full-stack | 3 | 16 | Less than 1 year | Very satisfied | Slightly satisfied | Very confident | No | Not sure | I am not interested in new job opportunities | Less than a year ago | Write code by hand (e.g., on a whiteboard);Int... | No | Languages, frameworks, and other technologies ... | I was preparing for a job search | USD | United States dollar | 61000.0 | Yearly | 61000.0 | 80.0 | There's no schedule or spec; I work on what se... | NaN | Less than once per month / Never | Home | A little below average | No | NaN | No, but I think we should | Developers typically have the most influence o... | I have little or no influence | C;C++;C#;Python;SQL | C;C#;JavaScript;SQL | MySQL;SQLite | MySQL;SQLite | Linux;Windows | Linux;Windows | NaN | NaN | .NET | .NET | Eclipse;Vim;Visual Studio;Visual Studio Code | Windows | I do not use containers | Not at all | Useful for decentralized currency (i.e., Bitcoin) | Yes | SIGH | Yes | Reddit | In real life (in person) | Username | 2014 | Daily or almost daily | Find answers to specific questions;Pass the ti... | 1-2 times per week | Stack Overflow was much faster | 31-60 minutes | Yes | Less than once per month or monthly | Yes | No, and I don't know what those are | No, not really | Just as welcome now as I felt last year | Tech articles written by other developers;Indu... | 22.0 | Man | No | Straight / Heterosexual | White or of European descent | No | Appropriate in length | Easy |
|---|
| 5 | I am a developer by profession | Yes | Once a month or more often | OSS is, on average, of HIGHER quality than pro... | Employed full-time | Ukraine | No | Bachelor’s degree (BA, BS, B.Eng., etc.) | Computer science, computer engineering, or sof... | Taken an online course in programming or softw... | 10,000 or more employees | Academic researcher;Developer, desktop or ente... | 16 | 14 | 9 | Very dissatisfied | Slightly dissatisfied | Somewhat confident | Yes | No | I am not interested in new job opportunities | Less than a year ago | Write any code;Write code by hand (e.g., on a ... | No | Industry that I'd be working in;Languages, fra... | I was preparing for a job search | UAH | Ukrainian hryvnia | NaN | NaN | NaN | 55.0 | There is a schedule and/or spec (made by me or... | Being tasked with non-development work;Inadequ... | A few days each month | Office | A little above average | Yes, because I see value in code review | NaN | Yes, it's part of our process | Not sure | I have little or no influence | C++;HTML/CSS;Java;JavaScript;Python;SQL;VBA | HTML/CSS;Java;JavaScript;SQL;WebAssembly | Couchbase;MongoDB;MySQL;Oracle;PostgreSQL;SQLite | Couchbase;Firebase;MongoDB;MySQL;Oracle;Postgr... | Android;Linux;MacOS;Slack;Windows | Android;Docker;Kubernetes;Linux;Slack | Django;Express;Flask;jQuery;React.js;Spring | Flask;jQuery;React.js;Spring | Cordova;Node.js | Apache Spark;Hadoop;Node.js;React Native | IntelliJ;Notepad++;Vim | Linux-based | Outside of work, for personal projects | Not at all | NaN | Yes | Also Yes | Yes | Facebook | In real life (in person) | Username | I don't remember | Multiple times per day | Find answers to specific questions | More than 10 times per week | Stack Overflow was much faster | NaN | Yes | A few times per month or weekly | No, I knew that Stack Overflow had a job board... | No, I've heard of them, but I am not part of a... | Yes, definitely | Just as welcome now as I felt last year | Tech meetups or events in your area;Courses on... | 30.0 | Man | No | Straight / Heterosexual | White or of European descent;Multiracial | No | Appropriate in length | Easy |
|---|
df.loc[1]
MainBranch I am a student who is learning to code
Hobbyist Yes
OpenSourcer Never
OpenSource The quality of OSS and closed source software ...
Employment Not employed, and not looking for work
Country United Kingdom
Student No
EdLevel Primary/elementary school
UndergradMajor NaN
EduOther Taught yourself a new language, framework, or ...
OrgSize NaN
DevType NaN
YearsCode 4
Age1stCode 10
YearsCodePro NaN
CareerSat NaN
JobSat NaN
MgrIdiot NaN
MgrMoney NaN
MgrWant NaN
JobSeek NaN
LastHireDate NaN
LastInt NaN
FizzBuzz NaN
JobFactors NaN
ResumeUpdate NaN
CurrencySymbol NaN
CurrencyDesc NaN
CompTotal NaN
CompFreq NaN
ConvertedComp NaN
WorkWeekHrs NaN
WorkPlan NaN
WorkChallenge NaN
WorkRemote NaN
WorkLoc NaN
ImpSyn NaN
CodeRev NaN
CodeRevHrs NaN
UnitTests NaN
PurchaseHow NaN
PurchaseWhat NaN
LanguageWorkedWith HTML/CSS;Java;JavaScript;Python
LanguageDesireNextYear C;C++;C#;Go;HTML/CSS;Java;JavaScript;Python;SQL
DatabaseWorkedWith SQLite
DatabaseDesireNextYear MySQL
PlatformWorkedWith MacOS;Windows
PlatformDesireNextYear Android;Arduino;Windows
WebFrameWorkedWith Django;Flask
WebFrameDesireNextYear Flask;jQuery
MiscTechWorkedWith Node.js
MiscTechDesireNextYear Node.js
DevEnviron IntelliJ;Notepad++;PyCharm
OpSys Windows
Containers I do not use containers
BlockchainOrg NaN
BlockchainIs NaN
BetterLife Yes
ITperson Fortunately, someone else has that title
OffOn Yes
SocialMedia Twitter
Extraversion Online
ScreenName Username
SOVisit1st 2017
SOVisitFreq A few times per month or weekly
SOVisitTo Find answers to specific questions;Learn how t...
SOFindAnswer 3-5 times per week
SOTimeSaved Stack Overflow was much faster
SOHowMuchTime 31-60 minutes
SOAccount No
SOPartFreq NaN
SOJobs No, I didn't know that Stack Overflow had a jo...
EntTeams No, and I don't know what those are
SOComm Neutral
WelcomeChange Just as welcome now as I felt last year
SONewContent Tech articles written by other developers;Indu...
Age 14.0
Gender Man
Trans No
Sexuality Straight / Heterosexual
Ethnicity NaN
Dependents No
SurveyLength Appropriate in length
SurveyEase Neither easy nor difficult
Name: 1, dtype: object
df.iloc根据位置返回值,df.loc根据索引返回值,df.iloc[0]与df.loc[1]返回的结果一致
获取变量的含义
schema_df = pd.read_csv('data/survey_results_schema.csv',index_col='Column')
schema_df
| QuestionText |
|---|
| Column | |
|---|
| Respondent | Randomized respondent ID number (not in order ... |
|---|
| MainBranch | Which of the following options best describes ... |
|---|
| Hobbyist | Do you code as a hobby? |
|---|
| OpenSourcer | How often do you contribute to open source? |
|---|
| OpenSource | How do you feel about the quality of open sour... |
|---|
| Employment | Which of the following best describes your cur... |
|---|
| Country | In which country do you currently reside? |
|---|
| Student | Are you currently enrolled in a formal, degree... |
|---|
| EdLevel | Which of the following best describes the high... |
|---|
| UndergradMajor | What was your main or most important field of ... |
|---|
| EduOther | Which of the following types of non-degree edu... |
|---|
| OrgSize | Approximately how many people are employed by ... |
|---|
| DevType | Which of the following describe you? Please se... |
|---|
| YearsCode | Including any education, how many years have y... |
|---|
| Age1stCode | At what age did you write your first line of c... |
|---|
| YearsCodePro | How many years have you coded professionally (... |
|---|
| CareerSat | Overall, how satisfied are you with your caree... |
|---|
| JobSat | How satisfied are you with your current job? (... |
|---|
| MgrIdiot | How confident are you that your manager knows ... |
|---|
| MgrMoney | Do you believe that you need to be a manager t... |
|---|
| MgrWant | Do you want to become a manager yourself in th... |
|---|
| JobSeek | Which of the following best describes your cur... |
|---|
| LastHireDate | When was the last time that you took a job wit... |
|---|
| LastInt | In your most recent successful job interview (... |
|---|
| FizzBuzz | Have you ever been asked to solve FizzBuzz in ... |
|---|
| JobFactors | Imagine that you are deciding between two job ... |
|---|
| ResumeUpdate | Think back to the last time you updated your r... |
|---|
| CurrencySymbol | Which currency do you use day-to-day? If your ... |
|---|
| CurrencyDesc | Which currency do you use day-to-day? If your ... |
|---|
| CompTotal | What is your current total compensation (salar... |
|---|
| CompFreq | Is that compensation weekly, monthly, or yearly? |
|---|
| ConvertedComp | Salary converted to annual USD salaries using ... |
|---|
| WorkWeekHrs | On average, how many hours per week do you work? |
|---|
| WorkPlan | How structured or planned is your work? |
|---|
| WorkChallenge | Of these options, what are your greatest chall... |
|---|
| WorkRemote | How often do you work remotely? |
|---|
| WorkLoc | Where would you prefer to work? |
|---|
| ImpSyn | For the specific work you do, and the years of... |
|---|
| CodeRev | Do you review code as part of your work? |
|---|
| CodeRevHrs | On average, how many hours per week do you spe... |
|---|
| UnitTests | Does your company regularly employ unit tests ... |
|---|
| PurchaseHow | How does your company make decisions about pur... |
|---|
| PurchaseWhat | What level of influence do you, personally, ha... |
|---|
| LanguageWorkedWith | Which of the following programming, scripting,... |
|---|
| LanguageDesireNextYear | Which of the following programming, scripting,... |
|---|
| DatabaseWorkedWith | Which of the following database environments h... |
|---|
| DatabaseDesireNextYear | Which of the following database environments h... |
|---|
| PlatformWorkedWith | Which of the following platforms have you done... |
|---|
| PlatformDesireNextYear | Which of the following platforms have you done... |
|---|
| WebFrameWorkedWith | Which of the following web frameworks have you... |
|---|
| WebFrameDesireNextYear | Which of the following web frameworks have you... |
|---|
| MiscTechWorkedWith | Which of the following other frameworks, libra... |
|---|
| MiscTechDesireNextYear | Which of the following other frameworks, libra... |
|---|
| DevEnviron | Which development environment(s) do you use re... |
|---|
| OpSys | What is the primary operating system in which ... |
|---|
| Containers | How do you use containers (Docker, Open Contai... |
|---|
| BlockchainOrg | How is your organization thinking about or imp... |
|---|
| BlockchainIs | Blockchain / cryptocurrency technology is prim... |
|---|
| BetterLife | Do you think people born today will have a bet... |
|---|
| ITperson | Are you the "IT support person" for your family? |
|---|
| OffOn | Have you tried turning it off and on again? |
|---|
| SocialMedia | What social media site do you use the most? |
|---|
| Extraversion | Do you prefer online chat or IRL conversations? |
|---|
| ScreenName | What do you call it? |
|---|
| SOVisit1st | To the best of your memory, when did you first... |
|---|
| SOVisitFreq | How frequently would you say you visit Stack O... |
|---|
| SOVisitTo | I visit Stack Overflow to... (check all that a... |
|---|
| SOFindAnswer | On average, how many times a week do you find ... |
|---|
| SOTimeSaved | Think back to the last time you solved a codin... |
|---|
| SOHowMuchTime | About how much time did you save? If you're no... |
|---|
| SOAccount | Do you have a Stack Overflow account? |
|---|
| SOPartFreq | How frequently would you say you participate i... |
|---|
| SOJobs | Have you ever used or visited Stack Overflow J... |
|---|
| EntTeams | Have you ever used Stack Overflow for Enterpri... |
|---|
| SOComm | Do you consider yourself a member of the Stack... |
|---|
| WelcomeChange | Compared to last year, how welcome do you feel... |
|---|
| SONewContent | Would you like to see any of the following on ... |
|---|
| Age | What is your age (in years)? If you prefer not... |
|---|
| Gender | Which of the following do you currently identi... |
|---|
| Trans | Do you identify as transgender? |
|---|
| Sexuality | Which of the following do you currently identi... |
|---|
| Ethnicity | Which of the following do you identify as? Ple... |
|---|
| Dependents | Do you have any dependents (e.g., children, el... |
|---|
| SurveyLength | How do you feel about the length of the survey... |
|---|
| SurveyEase | How easy or difficult was this survey to compl... |
|---|
schema_df.loc['Hobbyist']
QuestionText Do you code as a hobby?
Name: Hobbyist, dtype: object
schema_df.loc['Hobbyist','QuestionText']
'Do you code as a hobby?'
按照索引排序
schema_df.sort_index()#如果降序使用schema_df.sort_index(ascending=False),同样也可使用inplace=True
| QuestionText |
|---|
| Column | |
|---|
| Age | What is your age (in years)? If you prefer not... |
|---|
| Age1stCode | At what age did you write your first line of c... |
|---|
| BetterLife | Do you think people born today will have a bet... |
|---|
| BlockchainIs | Blockchain / cryptocurrency technology is prim... |
|---|
| BlockchainOrg | How is your organization thinking about or imp... |
|---|
| CareerSat | Overall, how satisfied are you with your caree... |
|---|
| CodeRev | Do you review code as part of your work? |
|---|
| CodeRevHrs | On average, how many hours per week do you spe... |
|---|
| CompFreq | Is that compensation weekly, monthly, or yearly? |
|---|
| CompTotal | What is your current total compensation (salar... |
|---|
| Containers | How do you use containers (Docker, Open Contai... |
|---|
| ConvertedComp | Salary converted to annual USD salaries using ... |
|---|
| Country | In which country do you currently reside? |
|---|
| CurrencyDesc | Which currency do you use day-to-day? If your ... |
|---|
| CurrencySymbol | Which currency do you use day-to-day? If your ... |
|---|
| DatabaseDesireNextYear | Which of the following database environments h... |
|---|
| DatabaseWorkedWith | Which of the following database environments h... |
|---|
| Dependents | Do you have any dependents (e.g., children, el... |
|---|
| DevEnviron | Which development environment(s) do you use re... |
|---|
| DevType | Which of the following describe you? Please se... |
|---|
| EdLevel | Which of the following best describes the high... |
|---|
| EduOther | Which of the following types of non-degree edu... |
|---|
| Employment | Which of the following best describes your cur... |
|---|
| EntTeams | Have you ever used Stack Overflow for Enterpri... |
|---|
| Ethnicity | Which of the following do you identify as? Ple... |
|---|
| Extraversion | Do you prefer online chat or IRL conversations? |
|---|
| FizzBuzz | Have you ever been asked to solve FizzBuzz in ... |
|---|
| Gender | Which of the following do you currently identi... |
|---|
| Hobbyist | Do you code as a hobby? |
|---|
| ITperson | Are you the "IT support person" for your family? |
|---|
| ImpSyn | For the specific work you do, and the years of... |
|---|
| JobFactors | Imagine that you are deciding between two job ... |
|---|
| JobSat | How satisfied are you with your current job? (... |
|---|
| JobSeek | Which of the following best describes your cur... |
|---|
| LanguageDesireNextYear | Which of the following programming, scripting,... |
|---|
| LanguageWorkedWith | Which of the following programming, scripting,... |
|---|
| LastHireDate | When was the last time that you took a job wit... |
|---|
| LastInt | In your most recent successful job interview (... |
|---|
| MainBranch | Which of the following options best describes ... |
|---|
| MgrIdiot | How confident are you that your manager knows ... |
|---|
| MgrMoney | Do you believe that you need to be a manager t... |
|---|
| MgrWant | Do you want to become a manager yourself in th... |
|---|
| MiscTechDesireNextYear | Which of the following other frameworks, libra... |
|---|
| MiscTechWorkedWith | Which of the following other frameworks, libra... |
|---|
| OffOn | Have you tried turning it off and on again? |
|---|
| OpSys | What is the primary operating system in which ... |
|---|
| OpenSource | How do you feel about the quality of open sour... |
|---|
| OpenSourcer | How often do you contribute to open source? |
|---|
| OrgSize | Approximately how many people are employed by ... |
|---|
| PlatformDesireNextYear | Which of the following platforms have you done... |
|---|
| PlatformWorkedWith | Which of the following platforms have you done... |
|---|
| PurchaseHow | How does your company make decisions about pur... |
|---|
| PurchaseWhat | What level of influence do you, personally, ha... |
|---|
| Respondent | Randomized respondent ID number (not in order ... |
|---|
| ResumeUpdate | Think back to the last time you updated your r... |
|---|
| SOAccount | Do you have a Stack Overflow account? |
|---|
| SOComm | Do you consider yourself a member of the Stack... |
|---|
| SOFindAnswer | On average, how many times a week do you find ... |
|---|
| SOHowMuchTime | About how much time did you save? If you're no... |
|---|
| SOJobs | Have you ever used or visited Stack Overflow J... |
|---|
| SONewContent | Would you like to see any of the following on ... |
|---|
| SOPartFreq | How frequently would you say you participate i... |
|---|
| SOTimeSaved | Think back to the last time you solved a codin... |
|---|
| SOVisit1st | To the best of your memory, when did you first... |
|---|
| SOVisitFreq | How frequently would you say you visit Stack O... |
|---|
| SOVisitTo | I visit Stack Overflow to... (check all that a... |
|---|
| ScreenName | What do you call it? |
|---|
| Sexuality | Which of the following do you currently identi... |
|---|
| SocialMedia | What social media site do you use the most? |
|---|
| Student | Are you currently enrolled in a formal, degree... |
|---|
| SurveyEase | How easy or difficult was this survey to compl... |
|---|
| SurveyLength | How do you feel about the length of the survey... |
|---|
| Trans | Do you identify as transgender? |
|---|
| UndergradMajor | What was your main or most important field of ... |
|---|
| UnitTests | Does your company regularly employ unit tests ... |
|---|
| WebFrameDesireNextYear | Which of the following web frameworks have you... |
|---|
| WebFrameWorkedWith | Which of the following web frameworks have you... |
|---|
| WelcomeChange | Compared to last year, how welcome do you feel... |
|---|
| WorkChallenge | Of these options, what are your greatest chall... |
|---|
| WorkLoc | Where would you prefer to work? |
|---|
| WorkPlan | How structured or planned is your work? |
|---|
| WorkRemote | How often do you work remotely? |
|---|
| WorkWeekHrs | On average, how many hours per week do you work? |
|---|
| YearsCode | Including any education, how many years have y... |
|---|
| YearsCodePro | How many years have you coded professionally (... |
|---|
筛选
people = {
"first": ["Corey", 'Jane', 'John'],
"last": ["Schafer", 'Doe', 'Doe'],
"email": ["CoreyMSchafer@gmail", 'JaneDoe@email', 'JohnDoe@email']
}
import pandas as pd
df = pd.DataFrame(people)
df
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
df['last'] == 'Doe'
0 False
1 True
2 True
Name: last, dtype: bool
filt = (df['last'] == 'Doe')
df[filt]
| first | last | email |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
df[df['last'] == 'Doe']
| first | last | email |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
这种写法也可以
df.loc[filt]
| first | last | email |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
df.loc与df[filt]结果返回一样,df.loc更方便的一点是还可以继续访问列
df.loc[filt,'email']
1 JaneDoe@email
2 JohnDoe@email
Name: email, dtype: object
与或非
Pandas与Python内置函数不同不使用and和or,而使用&或者|
与
df
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
filt = (df['last'] == 'Doe') & (df['first'] == 'John')
df.loc[filt,'email']
2 JohnDoe@email
Name: email, dtype: object
或
df
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
filt = (df['last'] == 'Schafer') | (df['first'] == 'John')
df.loc[filt,'email']
0 CoreyMSchafer@gmail
2 JohnDoe@email
Name: email, dtype: object
非
df
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
df.loc[-filt,'email']
1 JaneDoe@email
Name: email, dtype: object
df = pd.read_csv('data/survey_results_public.csv',index_col='Respondent')
pd.set_option('display.max_columns', 85)
pd.set_option('display.max_rows', 85)
df.head()
| MainBranch | Hobbyist | OpenSourcer | OpenSource | Employment | Country | Student | EdLevel | UndergradMajor | EduOther | OrgSize | DevType | YearsCode | Age1stCode | YearsCodePro | CareerSat | JobSat | MgrIdiot | MgrMoney | MgrWant | JobSeek | LastHireDate | LastInt | FizzBuzz | JobFactors | ResumeUpdate | CurrencySymbol | CurrencyDesc | CompTotal | CompFreq | ConvertedComp | WorkWeekHrs | WorkPlan | WorkChallenge | WorkRemote | WorkLoc | ImpSyn | CodeRev | CodeRevHrs | UnitTests | PurchaseHow | PurchaseWhat | LanguageWorkedWith | LanguageDesireNextYear | DatabaseWorkedWith | DatabaseDesireNextYear | PlatformWorkedWith | PlatformDesireNextYear | WebFrameWorkedWith | WebFrameDesireNextYear | MiscTechWorkedWith | MiscTechDesireNextYear | DevEnviron | OpSys | Containers | BlockchainOrg | BlockchainIs | BetterLife | ITperson | OffOn | SocialMedia | Extraversion | ScreenName | SOVisit1st | SOVisitFreq | SOVisitTo | SOFindAnswer | SOTimeSaved | SOHowMuchTime | SOAccount | SOPartFreq | SOJobs | EntTeams | SOComm | WelcomeChange | SONewContent | Age | Gender | Trans | Sexuality | Ethnicity | Dependents | SurveyLength | SurveyEase |
|---|
| Respondent | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|---|
| 1 | I am a student who is learning to code | Yes | Never | The quality of OSS and closed source software ... | Not employed, and not looking for work | United Kingdom | No | Primary/elementary school | NaN | Taught yourself a new language, framework, or ... | NaN | NaN | 4 | 10 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | HTML/CSS;Java;JavaScript;Python | C;C++;C#;Go;HTML/CSS;Java;JavaScript;Python;SQL | SQLite | MySQL | MacOS;Windows | Android;Arduino;Windows | Django;Flask | Flask;jQuery | Node.js | Node.js | IntelliJ;Notepad++;PyCharm | Windows | I do not use containers | NaN | NaN | Yes | Fortunately, someone else has that title | Yes | Twitter | Online | Username | 2017 | A few times per month or weekly | Find answers to specific questions;Learn how t... | 3-5 times per week | Stack Overflow was much faster | 31-60 minutes | No | NaN | No, I didn't know that Stack Overflow had a jo... | No, and I don't know what those are | Neutral | Just as welcome now as I felt last year | Tech articles written by other developers;Indu... | 14.0 | Man | No | Straight / Heterosexual | NaN | No | Appropriate in length | Neither easy nor difficult |
|---|
| 2 | I am a student who is learning to code | No | Less than once per year | The quality of OSS and closed source software ... | Not employed, but looking for work | Bosnia and Herzegovina | Yes, full-time | Secondary school (e.g. American high school, G... | NaN | Taken an online course in programming or softw... | NaN | Developer, desktop or enterprise applications;... | NaN | 17 | NaN | NaN | NaN | NaN | NaN | NaN | I am actively looking for a job | I've never had a job | NaN | NaN | Financial performance or funding status of the... | Something else changed (education, award, medi... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | C++;HTML/CSS;Python | C++;HTML/CSS;JavaScript;SQL | NaN | MySQL | Windows | Windows | Django | Django | NaN | NaN | Atom;PyCharm | Windows | I do not use containers | NaN | Useful across many domains and could change ma... | Yes | Yes | Yes | Instagram | Online | Username | 2017 | Daily or almost daily | Find answers to specific questions;Learn how t... | 3-5 times per week | Stack Overflow was much faster | 11-30 minutes | Yes | A few times per month or weekly | No, I knew that Stack Overflow had a job board... | No, and I don't know what those are | Yes, somewhat | Just as welcome now as I felt last year | Tech articles written by other developers;Indu... | 19.0 | Man | No | Straight / Heterosexual | NaN | No | Appropriate in length | Neither easy nor difficult |
|---|
| 3 | I am not primarily a developer, but I write co... | Yes | Never | The quality of OSS and closed source software ... | Employed full-time | Thailand | No | Bachelor’s degree (BA, BS, B.Eng., etc.) | Web development or web design | Taught yourself a new language, framework, or ... | 100 to 499 employees | Designer;Developer, back-end;Developer, front-... | 3 | 22 | 1 | Slightly satisfied | Slightly satisfied | Not at all confident | Not sure | Not sure | I’m not actively looking, but I am open to new... | 1-2 years ago | Interview with people in peer roles | No | Languages, frameworks, and other technologies ... | I was preparing for a job search | THB | Thai baht | 23000.0 | Monthly | 8820.0 | 40.0 | There's no schedule or spec; I work on what se... | Distracting work environment;Inadequate access... | Less than once per month / Never | Home | Average | No | NaN | No, but I think we should | Not sure | I have little or no influence | HTML/CSS | Elixir;HTML/CSS | PostgreSQL | PostgreSQL | NaN | NaN | NaN | Other(s): | NaN | NaN | Vim;Visual Studio Code | Linux-based | I do not use containers | NaN | NaN | Yes | Yes | Yes | Reddit | In real life (in person) | Username | 2011 | A few times per week | Find answers to specific questions;Learn how t... | 6-10 times per week | They were about the same | NaN | Yes | Less than once per month or monthly | Yes | No, I've heard of them, but I am not part of a... | Neutral | Just as welcome now as I felt last year | Tech meetups or events in your area;Courses on... | 28.0 | Man | No | Straight / Heterosexual | NaN | Yes | Appropriate in length | Neither easy nor difficult |
|---|
| 4 | I am a developer by profession | No | Never | The quality of OSS and closed source software ... | Employed full-time | United States | No | Bachelor’s degree (BA, BS, B.Eng., etc.) | Computer science, computer engineering, or sof... | Taken an online course in programming or softw... | 100 to 499 employees | Developer, full-stack | 3 | 16 | Less than 1 year | Very satisfied | Slightly satisfied | Very confident | No | Not sure | I am not interested in new job opportunities | Less than a year ago | Write code by hand (e.g., on a whiteboard);Int... | No | Languages, frameworks, and other technologies ... | I was preparing for a job search | USD | United States dollar | 61000.0 | Yearly | 61000.0 | 80.0 | There's no schedule or spec; I work on what se... | NaN | Less than once per month / Never | Home | A little below average | No | NaN | No, but I think we should | Developers typically have the most influence o... | I have little or no influence | C;C++;C#;Python;SQL | C;C#;JavaScript;SQL | MySQL;SQLite | MySQL;SQLite | Linux;Windows | Linux;Windows | NaN | NaN | .NET | .NET | Eclipse;Vim;Visual Studio;Visual Studio Code | Windows | I do not use containers | Not at all | Useful for decentralized currency (i.e., Bitcoin) | Yes | SIGH | Yes | Reddit | In real life (in person) | Username | 2014 | Daily or almost daily | Find answers to specific questions;Pass the ti... | 1-2 times per week | Stack Overflow was much faster | 31-60 minutes | Yes | Less than once per month or monthly | Yes | No, and I don't know what those are | No, not really | Just as welcome now as I felt last year | Tech articles written by other developers;Indu... | 22.0 | Man | No | Straight / Heterosexual | White or of European descent | No | Appropriate in length | Easy |
|---|
| 5 | I am a developer by profession | Yes | Once a month or more often | OSS is, on average, of HIGHER quality than pro... | Employed full-time | Ukraine | No | Bachelor’s degree (BA, BS, B.Eng., etc.) | Computer science, computer engineering, or sof... | Taken an online course in programming or softw... | 10,000 or more employees | Academic researcher;Developer, desktop or ente... | 16 | 14 | 9 | Very dissatisfied | Slightly dissatisfied | Somewhat confident | Yes | No | I am not interested in new job opportunities | Less than a year ago | Write any code;Write code by hand (e.g., on a ... | No | Industry that I'd be working in;Languages, fra... | I was preparing for a job search | UAH | Ukrainian hryvnia | NaN | NaN | NaN | 55.0 | There is a schedule and/or spec (made by me or... | Being tasked with non-development work;Inadequ... | A few days each month | Office | A little above average | Yes, because I see value in code review | NaN | Yes, it's part of our process | Not sure | I have little or no influence | C++;HTML/CSS;Java;JavaScript;Python;SQL;VBA | HTML/CSS;Java;JavaScript;SQL;WebAssembly | Couchbase;MongoDB;MySQL;Oracle;PostgreSQL;SQLite | Couchbase;Firebase;MongoDB;MySQL;Oracle;Postgr... | Android;Linux;MacOS;Slack;Windows | Android;Docker;Kubernetes;Linux;Slack | Django;Express;Flask;jQuery;React.js;Spring | Flask;jQuery;React.js;Spring | Cordova;Node.js | Apache Spark;Hadoop;Node.js;React Native | IntelliJ;Notepad++;Vim | Linux-based | Outside of work, for personal projects | Not at all | NaN | Yes | Also Yes | Yes | Facebook | In real life (in person) | Username | I don't remember | Multiple times per day | Find answers to specific questions | More than 10 times per week | Stack Overflow was much faster | NaN | Yes | A few times per month or weekly | No, I knew that Stack Overflow had a job board... | No, I've heard of them, but I am not part of a... | Yes, definitely | Just as welcome now as I felt last year | Tech meetups or events in your area;Courses on... | 30.0 | Man | No | Straight / Heterosexual | White or of European descent;Multiracial | No | Appropriate in length | Easy |
|---|
例子
- 查找高薪数据
high_salary = (df['ConvertedComp'] > 70000)
df.loc[high_salary,['Country','LanguageWorkedWith','ConvertedComp']]
| Country | LanguageWorkedWith | ConvertedComp |
|---|
| Respondent | | | |
|---|
| 6 | Canada | Java;R;SQL | 366420.0 |
|---|
| 9 | New Zealand | Bash/Shell/PowerShell;C#;HTML/CSS;JavaScript;P... | 95179.0 |
|---|
| 13 | United States | Bash/Shell/PowerShell;HTML/CSS;JavaScript;PHP;... | 90000.0 |
|---|
| 16 | United Kingdom | Bash/Shell/PowerShell;C#;HTML/CSS;JavaScript;T... | 455352.0 |
|---|
| 22 | United States | Bash/Shell/PowerShell;C++;HTML/CSS;JavaScript;... | 103000.0 |
|---|
| ... | ... | ... | ... |
|---|
| 88876 | United States | Bash/Shell/PowerShell;C#;HTML/CSS;Java;Python;... | 180000.0 |
|---|
| 88877 | United States | Bash/Shell/PowerShell;C;Clojure;HTML/CSS;Java;... | 2000000.0 |
|---|
| 88878 | United States | HTML/CSS;JavaScript;Scala;TypeScript | 130000.0 |
|---|
| 88879 | Finland | Bash/Shell/PowerShell;C++;Python | 82488.0 |
|---|
| 88882 | Netherlands | C#;HTML/CSS;Java;JavaScript;PHP;Python | 588012.0 |
|---|
22289 rows × 3 columns
- 查找国家是United States’,‘India’,‘United Kingom’,‘German’,'Canada’的数据
coutries = ['United States','India','United Kingom','German','Canada']
filt = df['Country'].isin(coutries)
df.loc[filt,'Country']
Respondent
4 United States
6 Canada
8 India
10 India
12 Canada
...
85182 Canada
85642 United States
86012 India
88282 United States
88377 Canada
Name: Country, Length: 33405, dtype: object
- 查找LanguageWorkedWith包含python数据
filt = df['LanguageWorkedWith'].str.contains('Python',na=False)
df.loc[filt,'LanguageWorkedWith']
Respondent
1 HTML/CSS;Java;JavaScript;Python
2 C++;HTML/CSS;Python
4 C;C++;C#;Python;SQL
5 C++;HTML/CSS;Java;JavaScript;Python;SQL;VBA
8 Bash/Shell/PowerShell;C;C++;HTML/CSS;Java;Java...
...
84539 Bash/Shell/PowerShell;C;C++;HTML/CSS;Java;Java...
85738 Bash/Shell/PowerShell;C++;Python;Ruby;Other(s):
86566 Bash/Shell/PowerShell;HTML/CSS;Python;Other(s):
87739 C;C++;HTML/CSS;JavaScript;PHP;Python;SQL
88212 HTML/CSS;JavaScript;Python
Name: LanguageWorkedWith, Length: 36443, dtype: object
更改数据
people = {
"first": ["Corey", 'Jane', 'John'],
"last": ["Schafer", 'Doe', 'Doe'],
"email": ["CoreyMSchafer@gmail", 'JaneDoe@email', 'JohnDoe@email']
}
import pandas as pd
df = pd.DataFrame(people)
df
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
df.columns
Index(['first', 'last', 'email'], dtype='object')
更新列名
df.columns = ['first_name','last_name','email']
df
| first_name | last_name | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
df.columns = [x.upper() for x in df.columns]
df
| FIRST_NAME | LAST_NAME | EMAIL |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
df.columns = df.columns.str.replace('_',' ')
df
| FIRST NAME | LAST NAME | EMAIL |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
df.columns = ['first_name','last_name','email']
df
| first_name | last_name | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
df.rename(columns={'first_name':'first','last_name':'last'},inplace=True)
df
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
更新数据
df.loc[2] = ['John','Smith','JohnSmith@email']
df
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Smith | JohnSmith@email |
|---|
如果这个数据有85列,这种修改数据方法的方法将很麻烦
df.loc[2,['last','email']] = ['Doe','JohnDoe@email']
df
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
df.loc[2,'last'] = 'Smith'
df
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Smith | JohnDoe@email |
|---|
df.loc[2,'last'] = 'Doe'
df
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
filt = (df['email']=='JohnDoe@email')
df.loc[filt,'last'] = 'Smith'
df
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Smith | JohnDoe@email |
|---|
df[filt,‘last’] = 'Smith’是错误的,因为他不可以选择列
df['email'].str.lower()
0 coreymschafer@gmail
1 janedoe@email
2 johndoe@email
Name: email, dtype: object
df['email'] = df['email'].str.lower()
df
| first | last | email |
|---|
| 0 | Corey | Schafer | coreymschafer@gmail |
|---|
| 1 | Jane | Doe | janedoe@email |
|---|
| 2 | John | Smith | johndoe@email |
|---|
apply
df['email'].apply(len)
0 23
1 17
2 17
Name: email, dtype: int64
def update_email(email):
return email.upper()
df['email'].apply(update_email)
0 COREYMSCHAFER@GMAIL.COM
1 JANEDOE@EMAIL.COM
2 JOHNDOE@EMAIL.COM
Name: email, dtype: object
df['email'] = df['email'].apply(update_email)
df
| first | last | email |
|---|
| 0 | Corey | Schafer | COREYMSCHAFER@GMAIL.COM |
|---|
| 1 | Jane | Doe | JANEDOE@EMAIL.COM |
|---|
| 2 | John | Smith | JOHNDOE@EMAIL.COM |
|---|
df['email'] = df['email'].apply(lambda x: x.lower())
df
| first | last | email |
|---|
| 0 | Corey | Schafer | coreymschafer@gmail |
|---|
| 1 | Jane | Doe | janedoe@email |
|---|
| 2 | John | Smith | johndoe@email |
|---|
df.apply(len)
first 3
last 3
email 3
dtype: int64
df.apply(len,axis='columns')
0 3
1 3
2 3
dtype: int64
df.apply(pd.Series.min)
first Corey
last Doe
email coreymschafer@gmail
dtype: object
df.apply(lambda x:x.min())
first Corey
last Doe
email coreymschafer@gmail
dtype: object
applymap
df.applymap(len)
| first | last | email |
|---|
| 0 | 5 | 7 | 23 |
|---|
| 1 | 4 | 3 | 17 |
|---|
| 2 | 4 | 5 | 17 |
|---|
df.applymap(str.lower)
| first | last | email |
|---|
| 0 | corey | schafer | coreymschafer@gmail |
|---|
| 1 | jane | doe | janedoe@email |
|---|
| 2 | john | smith | johndoe@email |
|---|
map
df
| first | last | email |
|---|
| 0 | Corey | Schafer | coreymschafer@gmail |
|---|
| 1 | Jane | Doe | janedoe@email |
|---|
| 2 | John | Smith | johndoe@email |
|---|
df['first'].map({'Corey':'Chris','Jane':'Mary'})
0 Chris
1 Mary
2 NaN
Name: first, dtype: object
其他位置被替换成了空值,与自己的目的相违背,我们可以采用replace函数
replace
df['first'].replace({'Corey':'Chris','Jane':'Mary'})
0 Chris
1 Mary
2 John
Name: first, dtype: object
df = pd.read_csv('data/survey_results_public.csv',index_col='Respondent')
pd.set_option('display.max_columns', 85)
pd.set_option('display.max_rows', 85)
df.head()
| MainBranch | Hobbyist | OpenSourcer | OpenSource | Employment | Country | Student | EdLevel | UndergradMajor | EduOther | OrgSize | DevType | YearsCode | Age1stCode | YearsCodePro | CareerSat | JobSat | MgrIdiot | MgrMoney | MgrWant | JobSeek | LastHireDate | LastInt | FizzBuzz | JobFactors | ResumeUpdate | CurrencySymbol | CurrencyDesc | CompTotal | CompFreq | ConvertedComp | WorkWeekHrs | WorkPlan | WorkChallenge | WorkRemote | WorkLoc | ImpSyn | CodeRev | CodeRevHrs | UnitTests | PurchaseHow | PurchaseWhat | LanguageWorkedWith | LanguageDesireNextYear | DatabaseWorkedWith | DatabaseDesireNextYear | PlatformWorkedWith | PlatformDesireNextYear | WebFrameWorkedWith | WebFrameDesireNextYear | MiscTechWorkedWith | MiscTechDesireNextYear | DevEnviron | OpSys | Containers | BlockchainOrg | BlockchainIs | BetterLife | ITperson | OffOn | SocialMedia | Extraversion | ScreenName | SOVisit1st | SOVisitFreq | SOVisitTo | SOFindAnswer | SOTimeSaved | SOHowMuchTime | SOAccount | SOPartFreq | SOJobs | EntTeams | SOComm | WelcomeChange | SONewContent | Age | Gender | Trans | Sexuality | Ethnicity | Dependents | SurveyLength | SurveyEase |
|---|
| Respondent | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|---|
| 1 | I am a student who is learning to code | Yes | Never | The quality of OSS and closed source software ... | Not employed, and not looking for work | United Kingdom | No | Primary/elementary school | NaN | Taught yourself a new language, framework, or ... | NaN | NaN | 4 | 10 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | HTML/CSS;Java;JavaScript;Python | C;C++;C#;Go;HTML/CSS;Java;JavaScript;Python;SQL | SQLite | MySQL | MacOS;Windows | Android;Arduino;Windows | Django;Flask | Flask;jQuery | Node.js | Node.js | IntelliJ;Notepad++;PyCharm | Windows | I do not use containers | NaN | NaN | Yes | Fortunately, someone else has that title | Yes | Twitter | Online | Username | 2017 | A few times per month or weekly | Find answers to specific questions;Learn how t... | 3-5 times per week | Stack Overflow was much faster | 31-60 minutes | No | NaN | No, I didn't know that Stack Overflow had a jo... | No, and I don't know what those are | Neutral | Just as welcome now as I felt last year | Tech articles written by other developers;Indu... | 14.0 | Man | No | Straight / Heterosexual | NaN | No | Appropriate in length | Neither easy nor difficult |
|---|
| 2 | I am a student who is learning to code | No | Less than once per year | The quality of OSS and closed source software ... | Not employed, but looking for work | Bosnia and Herzegovina | Yes, full-time | Secondary school (e.g. American high school, G... | NaN | Taken an online course in programming or softw... | NaN | Developer, desktop or enterprise applications;... | NaN | 17 | NaN | NaN | NaN | NaN | NaN | NaN | I am actively looking for a job | I've never had a job | NaN | NaN | Financial performance or funding status of the... | Something else changed (education, award, medi... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | C++;HTML/CSS;Python | C++;HTML/CSS;JavaScript;SQL | NaN | MySQL | Windows | Windows | Django | Django | NaN | NaN | Atom;PyCharm | Windows | I do not use containers | NaN | Useful across many domains and could change ma... | Yes | Yes | Yes | Instagram | Online | Username | 2017 | Daily or almost daily | Find answers to specific questions;Learn how t... | 3-5 times per week | Stack Overflow was much faster | 11-30 minutes | Yes | A few times per month or weekly | No, I knew that Stack Overflow had a job board... | No, and I don't know what those are | Yes, somewhat | Just as welcome now as I felt last year | Tech articles written by other developers;Indu... | 19.0 | Man | No | Straight / Heterosexual | NaN | No | Appropriate in length | Neither easy nor difficult |
|---|
| 3 | I am not primarily a developer, but I write co... | Yes | Never | The quality of OSS and closed source software ... | Employed full-time | Thailand | No | Bachelor’s degree (BA, BS, B.Eng., etc.) | Web development or web design | Taught yourself a new language, framework, or ... | 100 to 499 employees | Designer;Developer, back-end;Developer, front-... | 3 | 22 | 1 | Slightly satisfied | Slightly satisfied | Not at all confident | Not sure | Not sure | I’m not actively looking, but I am open to new... | 1-2 years ago | Interview with people in peer roles | No | Languages, frameworks, and other technologies ... | I was preparing for a job search | THB | Thai baht | 23000.0 | Monthly | 8820.0 | 40.0 | There's no schedule or spec; I work on what se... | Distracting work environment;Inadequate access... | Less than once per month / Never | Home | Average | No | NaN | No, but I think we should | Not sure | I have little or no influence | HTML/CSS | Elixir;HTML/CSS | PostgreSQL | PostgreSQL | NaN | NaN | NaN | Other(s): | NaN | NaN | Vim;Visual Studio Code | Linux-based | I do not use containers | NaN | NaN | Yes | Yes | Yes | Reddit | In real life (in person) | Username | 2011 | A few times per week | Find answers to specific questions;Learn how t... | 6-10 times per week | They were about the same | NaN | Yes | Less than once per month or monthly | Yes | No, I've heard of them, but I am not part of a... | Neutral | Just as welcome now as I felt last year | Tech meetups or events in your area;Courses on... | 28.0 | Man | No | Straight / Heterosexual | NaN | Yes | Appropriate in length | Neither easy nor difficult |
|---|
| 4 | I am a developer by profession | No | Never | The quality of OSS and closed source software ... | Employed full-time | United States | No | Bachelor’s degree (BA, BS, B.Eng., etc.) | Computer science, computer engineering, or sof... | Taken an online course in programming or softw... | 100 to 499 employees | Developer, full-stack | 3 | 16 | Less than 1 year | Very satisfied | Slightly satisfied | Very confident | No | Not sure | I am not interested in new job opportunities | Less than a year ago | Write code by hand (e.g., on a whiteboard);Int... | No | Languages, frameworks, and other technologies ... | I was preparing for a job search | USD | United States dollar | 61000.0 | Yearly | 61000.0 | 80.0 | There's no schedule or spec; I work on what se... | NaN | Less than once per month / Never | Home | A little below average | No | NaN | No, but I think we should | Developers typically have the most influence o... | I have little or no influence | C;C++;C#;Python;SQL | C;C#;JavaScript;SQL | MySQL;SQLite | MySQL;SQLite | Linux;Windows | Linux;Windows | NaN | NaN | .NET | .NET | Eclipse;Vim;Visual Studio;Visual Studio Code | Windows | I do not use containers | Not at all | Useful for decentralized currency (i.e., Bitcoin) | Yes | SIGH | Yes | Reddit | In real life (in person) | Username | 2014 | Daily or almost daily | Find answers to specific questions;Pass the ti... | 1-2 times per week | Stack Overflow was much faster | 31-60 minutes | Yes | Less than once per month or monthly | Yes | No, and I don't know what those are | No, not really | Just as welcome now as I felt last year | Tech articles written by other developers;Indu... | 22.0 | Man | No | Straight / Heterosexual | White or of European descent | No | Appropriate in length | Easy |
|---|
| 5 | I am a developer by profession | Yes | Once a month or more often | OSS is, on average, of HIGHER quality than pro... | Employed full-time | Ukraine | No | Bachelor’s degree (BA, BS, B.Eng., etc.) | Computer science, computer engineering, or sof... | Taken an online course in programming or softw... | 10,000 or more employees | Academic researcher;Developer, desktop or ente... | 16 | 14 | 9 | Very dissatisfied | Slightly dissatisfied | Somewhat confident | Yes | No | I am not interested in new job opportunities | Less than a year ago | Write any code;Write code by hand (e.g., on a ... | No | Industry that I'd be working in;Languages, fra... | I was preparing for a job search | UAH | Ukrainian hryvnia | NaN | NaN | NaN | 55.0 | There is a schedule and/or spec (made by me or... | Being tasked with non-development work;Inadequ... | A few days each month | Office | A little above average | Yes, because I see value in code review | NaN | Yes, it's part of our process | Not sure | I have little or no influence | C++;HTML/CSS;Java;JavaScript;Python;SQL;VBA | HTML/CSS;Java;JavaScript;SQL;WebAssembly | Couchbase;MongoDB;MySQL;Oracle;PostgreSQL;SQLite | Couchbase;Firebase;MongoDB;MySQL;Oracle;Postgr... | Android;Linux;MacOS;Slack;Windows | Android;Docker;Kubernetes;Linux;Slack | Django;Express;Flask;jQuery;React.js;Spring | Flask;jQuery;React.js;Spring | Cordova;Node.js | Apache Spark;Hadoop;Node.js;React Native | IntelliJ;Notepad++;Vim | Linux-based | Outside of work, for personal projects | Not at all | NaN | Yes | Also Yes | Yes | Facebook | In real life (in person) | Username | I don't remember | Multiple times per day | Find answers to specific questions | More than 10 times per week | Stack Overflow was much faster | NaN | Yes | A few times per month or weekly | No, I knew that Stack Overflow had a job board... | No, I've heard of them, but I am not part of a... | Yes, definitely | Just as welcome now as I felt last year | Tech meetups or events in your area;Courses on... | 30.0 | Man | No | Straight / Heterosexual | White or of European descent;Multiracial | No | Appropriate in length | Easy |
|---|
df.rename(columns={'ConvertedComp':'SalaryUSD'},inplace=True)
df['SalaryUSD']
Respondent
1 NaN
2 NaN
3 8820.0
4 61000.0
5 NaN
...
88377 NaN
88601 NaN
88802 NaN
88816 NaN
88863 NaN
Name: SalaryUSD, Length: 88883, dtype: float64
df['Hobbyist']
Respondent
1 Yes
2 No
3 Yes
4 No
5 Yes
...
88377 Yes
88601 No
88802 No
88816 No
88863 Yes
Name: Hobbyist, Length: 88883, dtype: object
df['Hobbyist'].map({'Yes':'True','No':'False'})
Respondent
1 True
2 False
3 True
4 False
5 True
...
88377 True
88601 False
88802 False
88816 False
88863 True
Name: Hobbyist, Length: 88883, dtype: object
添加/删除行和列
people = {
"first": ["Corey", 'Jane', 'John'],
"last": ["Schafer", 'Doe', 'Doe'],
"email": ["CoreyMSchafer@gmail", 'JaneDoe@email', 'JohnDoe@email']
}
import pandas as pd
df = pd.DataFrame(people)
df
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
合并列
df['first'] + ' ' + df['last']
0 Corey Schafer
1 Jane Doe
2 John Doe
dtype: object
df['full_name'] = df['first'] + ' ' + df['last']
df
| first | last | email | full_name |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail | Corey Schafer |
|---|
| 1 | Jane | Doe | JaneDoe@email | Jane Doe |
|---|
| 2 | John | Doe | JohnDoe@email | John Doe |
|---|
删除列
df.drop(columns=['first','last'],inplace=True)
df
| email | full_name |
|---|
| 0 | CoreyMSchafer@gmail | Corey Schafer |
|---|
| 1 | JaneDoe@email | Jane Doe |
|---|
| 2 | JohnDoe@email | John Doe |
|---|
拆分列
df['full_name'].str.split(' ')
0 [Corey, Schafer]
1 [Jane, Doe]
2 [John, Doe]
Name: full_name, dtype: object
df['full_name'].str.split(' ',expand=True)
| 0 | 1 |
|---|
| 0 | Corey | Schafer |
|---|
| 1 | Jane | Doe |
|---|
| 2 | John | Doe |
|---|
df[['first','last']] = df['full_name'].str.split(' ',expand=True)
df
| email | full_name | first | last |
|---|
| 0 | CoreyMSchafer@gmail | Corey Schafer | Corey | Schafer |
|---|
| 1 | JaneDoe@email | Jane Doe | Jane | Doe |
|---|
| 2 | JohnDoe@email | John Doe | John | Doe |
|---|
添加数据
df.append({'first':'Tony'},ignore_index=True)
| email | full_name | first | last |
|---|
| 0 | CoreyMSchafer@gmail | Corey Schafer | Corey | Schafer |
|---|
| 1 | JaneDoe@email | Jane Doe | Jane | Doe |
|---|
| 2 | JohnDoe@email | John Doe | John | Doe |
|---|
| 3 | NaN | NaN | Tony | NaN |
|---|
合并Dataframe
people = {
"first": ["Tony", 'Steve'],
"last": ["Stark", 'Rogers'],
"email": ["IronMan@avenge", 'Cap@avenge']
}
df2 = pd.DataFrame(people)
df2
| first | last | email |
|---|
| 0 | Tony | Stark | IronMan@avenge |
|---|
| 1 | Steve | Rogers | Cap@avenge |
|---|
df.append(df2,ignore_index=True)
| email | full_name | first | last |
|---|
| 0 | CoreyMSchafer@gmail | Corey Schafer | Corey | Schafer |
|---|
| 1 | JaneDoe@email | Jane Doe | Jane | Doe |
|---|
| 2 | JohnDoe@email | John Doe | John | Doe |
|---|
| 3 | IronMan@avenge | NaN | Tony | Stark |
|---|
| 4 | Cap@avenge | NaN | Steve | Rogers |
|---|
df = df.append(df2,ignore_index=True)
df
| email | full_name | first | last |
|---|
| 0 | CoreyMSchafer@gmail | Corey Schafer | Corey | Schafer |
|---|
| 1 | JaneDoe@email | Jane Doe | Jane | Doe |
|---|
| 2 | JohnDoe@email | John Doe | John | Doe |
|---|
| 3 | IronMan@avenge | NaN | Tony | Stark |
|---|
| 4 | Cap@avenge | NaN | Steve | Rogers |
|---|
删除行
df.drop(index=4)
| email | full_name | first | last |
|---|
| 0 | CoreyMSchafer@gmail | Corey Schafer | Corey | Schafer |
|---|
| 1 | JaneDoe@email | Jane Doe | Jane | Doe |
|---|
| 2 | JohnDoe@email | John Doe | John | Doe |
|---|
| 3 | IronMan@avenge | NaN | Tony | Stark |
|---|
df.drop(index=[2,3])
| email | full_name | first | last |
|---|
| 0 | CoreyMSchafer@gmail | Corey Schafer | Corey | Schafer |
|---|
| 1 | JaneDoe@email | Jane Doe | Jane | Doe |
|---|
| 4 | Cap@avenge | NaN | Steve | Rogers |
|---|
filt = df['last'] == 'Doe'
df.drop(index=df[filt].index)
| email | full_name | first | last |
|---|
| 0 | CoreyMSchafer@gmail | Corey Schafer | Corey | Schafer |
|---|
| 3 | IronMan@avenge | NaN | Tony | Stark |
|---|
| 4 | Cap@avenge | NaN | Steve | Rogers |
|---|
数据排序
people = {
"first": ["Corey", 'Jane', 'John','Adam'],
"last": ["Schafer", 'Doe', 'Doe','Doe'],
"email": ["CoreyMSchafer@gmail", 'JaneDoe@email', 'JohnDoe@email','A@email']
}
import pandas as pd
df = pd.DataFrame(people)
df
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
| 3 | Adam | Doe | A@email |
|---|
sort_values()
df.sort_values(by='last')
| first | last | email |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
| 3 | Adam | Doe | A@email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
df.sort_values(by='last',ascending=False)
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
| 3 | Adam | Doe | A@email |
|---|
df.sort_values(by=['last','first'],ascending=False)
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 3 | Adam | Doe | A@email |
|---|
df.sort_values(by=['last','first'],ascending=[False,True])#也有inplace参数
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 3 | Adam | Doe | A@email |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
按照索引排序
df.sort_index()
| first | last | email |
|---|
| 0 | Corey | Schafer | CoreyMSchafer@gmail |
|---|
| 1 | Jane | Doe | JaneDoe@email |
|---|
| 2 | John | Doe | JohnDoe@email |
|---|
| 3 | Adam | Doe | A@email |
|---|
df['last'].sort_values()
1 Doe
2 Doe
3 Doe
0 Schafer
Name: last, dtype: object
df = pd.read_csv('data/survey_results_public.csv',index_col='Respondent')
pd.set_option('display.max_columns', 85)
pd.set_option('display.max_rows', 85)
df.head(3)
| MainBranch | Hobbyist | OpenSourcer | OpenSource | Employment | Country | Student | EdLevel | UndergradMajor | EduOther | OrgSize | DevType | YearsCode | Age1stCode | YearsCodePro | CareerSat | JobSat | MgrIdiot | MgrMoney | MgrWant | JobSeek | LastHireDate | LastInt | FizzBuzz | JobFactors | ResumeUpdate | CurrencySymbol | CurrencyDesc | CompTotal | CompFreq | ConvertedComp | WorkWeekHrs | WorkPlan | WorkChallenge | WorkRemote | WorkLoc | ImpSyn | CodeRev | CodeRevHrs | UnitTests | PurchaseHow | PurchaseWhat | LanguageWorkedWith | LanguageDesireNextYear | DatabaseWorkedWith | DatabaseDesireNextYear | PlatformWorkedWith | PlatformDesireNextYear | WebFrameWorkedWith | WebFrameDesireNextYear | MiscTechWorkedWith | MiscTechDesireNextYear | DevEnviron | OpSys | Containers | BlockchainOrg | BlockchainIs | BetterLife | ITperson | OffOn | SocialMedia | Extraversion | ScreenName | SOVisit1st | SOVisitFreq | SOVisitTo | SOFindAnswer | SOTimeSaved | SOHowMuchTime | SOAccount | SOPartFreq | SOJobs | EntTeams | SOComm | WelcomeChange | SONewContent | Age | Gender | Trans | Sexuality | Ethnicity | Dependents | SurveyLength | SurveyEase |
|---|
| Respondent | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|---|
| 1 | I am a student who is learning to code | Yes | Never | The quality of OSS and closed source software ... | Not employed, and not looking for work | United Kingdom | No | Primary/elementary school | NaN | Taught yourself a new language, framework, or ... | NaN | NaN | 4 | 10 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | HTML/CSS;Java;JavaScript;Python | C;C++;C#;Go;HTML/CSS;Java;JavaScript;Python;SQL | SQLite | MySQL | MacOS;Windows | Android;Arduino;Windows | Django;Flask | Flask;jQuery | Node.js | Node.js | IntelliJ;Notepad++;PyCharm | Windows | I do not use containers | NaN | NaN | Yes | Fortunately, someone else has that title | Yes | Twitter | Online | Username | 2017 | A few times per month or weekly | Find answers to specific questions;Learn how t... | 3-5 times per week | Stack Overflow was much faster | 31-60 minutes | No | NaN | No, I didn't know that Stack Overflow had a jo... | No, and I don't know what those are | Neutral | Just as welcome now as I felt last year | Tech articles written by other developers;Indu... | 14.0 | Man | No | Straight / Heterosexual | NaN | No | Appropriate in length | Neither easy nor difficult |
|---|
| 2 | I am a student who is learning to code | No | Less than once per year | The quality of OSS and closed source software ... | Not employed, but looking for work | Bosnia and Herzegovina | Yes, full-time | Secondary school (e.g. American high school, G... | NaN | Taken an online course in programming or softw... | NaN | Developer, desktop or enterprise applications;... | NaN | 17 | NaN | NaN | NaN | NaN | NaN | NaN | I am actively looking for a job | I've never had a job | NaN | NaN | Financial performance or funding status of the... | Something else changed (education, award, medi... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | C++;HTML/CSS;Python | C++;HTML/CSS;JavaScript;SQL | NaN | MySQL | Windows | Windows | Django | Django | NaN | NaN | Atom;PyCharm | Windows | I do not use containers | NaN | Useful across many domains and could change ma... | Yes | Yes | Yes | Instagram | Online | Username | 2017 | Daily or almost daily | Find answers to specific questions;Learn how t... | 3-5 times per week | Stack Overflow was much faster | 11-30 minutes | Yes | A few times per month or weekly | No, I knew that Stack Overflow had a job board... | No, and I don't know what those are | Yes, somewhat | Just as welcome now as I felt last year | Tech articles written by other developers;Indu... | 19.0 | Man | No | Straight / Heterosexual | NaN | No | Appropriate in length | Neither easy nor difficult |
|---|
| 3 | I am not primarily a developer, but I write co... | Yes | Never | The quality of OSS and closed source software ... | Employed full-time | Thailand | No | Bachelor’s degree (BA, BS, B.Eng., etc.) | Web development or web design | Taught yourself a new language, framework, or ... | 100 to 499 employees | Designer;Developer, back-end;Developer, front-... | 3 | 22 | 1 | Slightly satisfied | Slightly satisfied | Not at all confident | Not sure | Not sure | I’m not actively looking, but I am open to new... | 1-2 years ago | Interview with people in peer roles | No | Languages, frameworks, and other technologies ... | I was preparing for a job search | THB | Thai baht | 23000.0 | Monthly | 8820.0 | 40.0 | There's no schedule or spec; I work on what se... | Distracting work environment;Inadequate access... | Less than once per month / Never | Home | Average | No | NaN | No, but I think we should | Not sure | I have little or no influence | HTML/CSS | Elixir;HTML/CSS | PostgreSQL | PostgreSQL | NaN | NaN | NaN | Other(s): | NaN | NaN | Vim;Visual Studio Code | Linux-based | I do not use containers | NaN | NaN | Yes | Yes | Yes | Reddit | In real life (in person) | Username | 2011 | A few times per week | Find answers to specific questions;Learn how t... | 6-10 times per week | They were about the same | NaN | Yes | Less than once per month or monthly | Yes | No, I've heard of them, but I am not part of a... | Neutral | Just as welcome now as I felt last year | Tech meetups or events in your area;Courses on... | 28.0 | Man | No | Straight / Heterosexual | NaN | Yes | Appropriate in length | Neither easy nor difficult |
|---|
df.sort_values(by=['Country','ConvertedComp'],ascending=[True,False],inplace=True)
df[['Country','ConvertedComp']].head(50)
| Country | ConvertedComp |
|---|
| Respondent | | |
|---|
| 63129 | Afghanistan | 1000000.0 |
|---|
| 50499 | Afghanistan | 153216.0 |
|---|
| 39258 | Afghanistan | 19152.0 |
|---|
| 58450 | Afghanistan | 17556.0 |
|---|
| 7085 | Afghanistan | 14364.0 |
|---|
| 22450 | Afghanistan | 7980.0 |
|---|
| 48436 | Afghanistan | 4464.0 |
|---|
| 10746 | Afghanistan | 3996.0 |
|---|
| 8149 | Afghanistan | 1596.0 |
|---|
| 29736 | Afghanistan | 1116.0 |
|---|
| 28638 | Afghanistan | 0.0 |
|---|
| 722 | Afghanistan | 0.0 |
|---|
| 62168 | Afghanistan | NaN |
|---|
| 85715 | Afghanistan | NaN |
|---|
| 50767 | Afghanistan | NaN |
|---|
| 2782 | Afghanistan | NaN |
|---|
| 63019 | Afghanistan | NaN |
|---|
| 6417 | Afghanistan | NaN |
|---|
| 40000 | Afghanistan | NaN |
|---|
| 88731 | Afghanistan | NaN |
|---|
| 85825 | Afghanistan | NaN |
|---|
| 62525 | Afghanistan | NaN |
|---|
| 49702 | Afghanistan | NaN |
|---|
| 33178 | Afghanistan | NaN |
|---|
| 60946 | Afghanistan | NaN |
|---|
| 86362 | Afghanistan | NaN |
|---|
| 88582 | Afghanistan | NaN |
|---|
| 86932 | Afghanistan | NaN |
|---|
| 7353 | Afghanistan | NaN |
|---|
| 26340 | Afghanistan | NaN |
|---|
| 58760 | Afghanistan | NaN |
|---|
| 74386 | Afghanistan | NaN |
|---|
| 29045 | Afghanistan | NaN |
|---|
| 51859 | Afghanistan | NaN |
|---|
| 45854 | Afghanistan | NaN |
|---|
| 47110 | Afghanistan | NaN |
|---|
| 44403 | Afghanistan | NaN |
|---|
| 80926 | Afghanistan | NaN |
|---|
| 59560 | Afghanistan | NaN |
|---|
| 60569 | Afghanistan | NaN |
|---|
| 37802 | Afghanistan | NaN |
|---|
| 43106 | Afghanistan | NaN |
|---|
| 12310 | Afghanistan | NaN |
|---|
| 87091 | Afghanistan | NaN |
|---|
| 38308 | Albania | 187668.0 |
|---|
| 3787 | Albania | 114550.0 |
|---|
| 9270 | Albania | 74474.0 |
|---|
| 6716 | Albania | 60000.0 |
|---|
| 10303 | Albania | 57300.0 |
|---|
| 66280 | Albania | 41244.0 |
|---|
查看某列前10大
df['ConvertedComp'].nlargest(10)
Respondent
25983 2000000.0
87896 2000000.0
22013 2000000.0
28243 2000000.0
72732 2000000.0
78151 2000000.0
80200 2000000.0
52132 2000000.0
75561 2000000.0
32250 2000000.0
Name: ConvertedComp, dtype: float64
df.nlargest(10,'ConvertedComp')#df.nsmallest
| MainBranch | Hobbyist | OpenSourcer | OpenSource | Employment | Country | Student | EdLevel | UndergradMajor | EduOther | OrgSize | DevType | YearsCode | Age1stCode | YearsCodePro | CareerSat | JobSat | MgrIdiot | MgrMoney | MgrWant | JobSeek | LastHireDate | LastInt | FizzBuzz | JobFactors | ResumeUpdate | CurrencySymbol | CurrencyDesc | CompTotal | CompFreq | ConvertedComp | WorkWeekHrs | WorkPlan | WorkChallenge | WorkRemote | WorkLoc | ImpSyn | CodeRev | CodeRevHrs | UnitTests | PurchaseHow | PurchaseWhat | LanguageWorkedWith | LanguageDesireNextYear | DatabaseWorkedWith | DatabaseDesireNextYear | PlatformWorkedWith | PlatformDesireNextYear | WebFrameWorkedWith | WebFrameDesireNextYear | MiscTechWorkedWith | MiscTechDesireNextYear | DevEnviron | OpSys | Containers | BlockchainOrg | BlockchainIs | BetterLife | ITperson | OffOn | SocialMedia | Extraversion | ScreenName | SOVisit1st | SOVisitFreq | SOVisitTo | SOFindAnswer | SOTimeSaved | SOHowMuchTime | SOAccount | SOPartFreq | SOJobs | EntTeams | SOComm | WelcomeChange | SONewContent | Age | Gender | Trans | Sexuality | Ethnicity | Dependents | SurveyLength | SurveyEase |
|---|
| Respondent | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|---|
| 25983 | I am a developer by profession | Yes | Less than once per year | OSS is, on average, of HIGHER quality than pro... | Employed full-time | Canada | No | Bachelor’s degree (BA, BS, B.Eng., etc.) | Computer science, computer engineering, or sof... | Received on-the-job training in software devel... | 10,000 or more employees | Developer, full-stack | 8 | 16 | 2 | Very satisfied | Very satisfied | Somewhat confident | No | No | I’m not actively looking, but I am open to new... | 3-4 years ago | Solve a brain-teaser style puzzle;Interview wi... | No | Remote work options;Opportunities for professi... | My job status changed (promotion, new job, etc.) | USD | United States dollar | 65500.0 | Weekly | 2000000.0 | 45.0 | There is a schedule and/or spec (made by me or... | Being tasked with non-development work;Meeting... | A few days each month | Office | Average | Yes, because I see value in code review | 2.0 | Yes, it's part of our process | Developers and management have nearly equal in... | I have little or no influence | Bash/Shell/PowerShell;C++;C#;HTML/CSS;JavaScri... | Bash/Shell/PowerShell;C#;F#;Python;SQL;TypeScript | Microsoft SQL Server;MySQL | Microsoft SQL Server;MySQL | AWS;Docker;Heroku;Linux;MacOS;Raspberry Pi;Win... | AWS;Docker;Linux;MacOS;Windows | Angular/Angular.js | Angular/Angular.js;Flask;React.js | .NET;.NET Core;Node.js | .NET Core;Node.js | Notepad++;Sublime Text;Vim;Visual Studio;Visua... | Windows | Development;Production | NaN | Useful for decentralized currency (i.e., Bitcoin) | No | Yes | Yes | Reddit | In real life (in person) | Username | 2013 | Daily or almost daily | Find answers to specific questions;Learn how t... | 1-2 times per week | Stack Overflow was much faster | 11-30 minutes | Yes | Less than once per month or monthly | No, I knew that Stack Overflow had a job board... | No, and I don't know what those are | No, not really | Just as welcome now as I felt last year | NaN | 24.0 | Man | No | Straight / Heterosexual | White or of European descent | No | Appropriate in length | Easy |
|---|
| 87896 | I am a developer by profession | Yes | Less than once per year | The quality of OSS and closed source software ... | Employed full-time | Germany | No | Bachelor’s degree (BA, BS, B.Eng., etc.) | Computer science, computer engineering, or sof... | Taken an online course in programming or softw... | 2-9 employees | Developer, full-stack | 9 | 17 | 8 | Very satisfied | Very satisfied | Somewhat confident | No | I am already a manager | I am not interested in new job opportunities | More than 4 years ago | Write any code;Interview with people in senior... | No | Office environment or company culture;Diversit... | Something else changed (education, award, medi... | USD | United States dollar | 55000.0 | Weekly | 2000000.0 | 40.0 | There is a schedule and/or spec (made by me or... | Being tasked with non-development work;Meeting... | All or almost all the time (I'm full-time remote) | Home | A little above average | Yes, because I see value in code review | 3.0 | No, but I think we should | Developers and management have nearly equal in... | I have a great deal of influence | HTML/CSS;JavaScript;PHP;SQL | HTML/CSS;JavaScript;PHP;Ruby;SQL;TypeScript | MariaDB;MySQL;PostgreSQL | MariaDB;MySQL;PostgreSQL | WordPress | NaN | jQuery;Laravel;Vue.js | Express;Laravel;Ruby on Rails;Vue.js | NaN | Node.js | Sublime Text;Vim;Visual Studio Code | Linux-based | I do not use containers | Not at all | Useful for immutable record keeping outside of... | No | Yes | Yes | Twitter | Online | Handle | 2011 | Daily or almost daily | Find answers to specific questions | 3-5 times per week | Stack Overflow was much faster | 0-10 minutes | Yes | Less than once per month or monthly | No, I knew that Stack Overflow had a job board... | No, I've heard of them, but I am not part of a... | No, not really | Just as welcome now as I felt last year | Tech articles written by other developers;Tech... | 32.0 | Man | No | Gay or Lesbian | White or of European descent | No | Appropriate in length | Neither easy nor difficult |
|---|
| 22013 | I am a developer by profession | Yes | Never | The quality of OSS and closed source software ... | Employed full-time | India | No | Professional degree (JD, MD, etc.) | A natural science (ex. biology, chemistry, phy... | Taken an online course in programming or softw... | 2-9 employees | Academic researcher;Data scientist or machine ... | 3 | 26 | 3 | Very satisfied | Very satisfied | NaN | NaN | NaN | I am not interested in new job opportunities | 3-4 years ago | Write code by hand (e.g., on a whiteboard);Com... | No | Financial performance or funding status of the... | Something else changed (education, award, medi... | USD | United States dollar | 1500000.0 | Weekly | 2000000.0 | 50.0 | There's no schedule or spec; I work on what se... | Inadequate access to necessary tools;Meetings;... | All or almost all the time (I'm full-time remote) | Home | A little below average | Yes, because I see value in code review | 10.0 | Yes, it's part of our process | Developers typically have the most influence o... | I have a great deal of influence | Assembly;Bash/Shell/PowerShell;C;C++;Java;Java... | Python;Swift | Cassandra;Microsoft SQL Server;Oracle | Cassandra | Android;Arduino;Google Cloud Platform;IBM Clou... | IBM Cloud or Watson;Windows | jQuery | NaN | TensorFlow | TensorFlow | Visual Studio;Visual Studio Code | Windows | Development | Implementing our own cryptocurrency | Useful across many domains and could change ma... | Yes | Yes | No | YouTube | Online | Screen Name | NaN | A few times per week | Find answers to specific questions | 1-2 times per week | Stack Overflow was much faster | 60+ minutes | Yes | I have never participated in Q&a |
|---|
本文标签:
第一部分
pandas
发表评论