Skip to content

Intro to Python Chaper - #10

Merged
cansavvy merged 24 commits into
mainfrom
howardbaek/r-vs-python
Jul 9, 2024
Merged

Intro to Python Chaper#10
cansavvy merged 24 commits into
mainfrom
howardbaek/r-vs-python

Conversation

@howardbaik

@howardbaikhowardbaik commented Feb 12, 2024

Copy link
Copy Markdown
Contributor

Purpose/implementation Section

What changes are being implemented in this Pull Request?

First draft of the "Intro to Python" chapter.

What was your approach?

I start with an introduction to Python, then touch on the main differences between R and Python, then talk about the major differences in Python for R users, which are mainly drawn from Primer on Python for R Users. Importantly, I briefly talk about OOP and classes, giving a small code snippet of a class in Python.

What GitHub issue does your pull request address?

This PR addresses #2

Tell potential reviewers what kind of feedback you are soliciting.

Open to any feedback or comments!

New Content Checklist

@howardbaikhowardbaik linked an issue Feb 12, 2024 that may be closed by this pull request
@github-actions

github-actionsBot commented Feb 12, 2024

Copy link
Copy Markdown

No broken urls! 🎉
Comment updated at 2024-02-15 with changes from 276e4fb

@github-actions

github-actionsBot commented Feb 12, 2024

Copy link
Copy Markdown

No spelling errors! 🎉
Comment updated at 2024-07-09-18:11:36 with changes from 0d537dc

@tillahoffmanntillahoffmann left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! I've left a few specific comments inline. A few additional questions:

  • I couldn't see the two png files being referenced in the markdown. Should they be removed?
  • Maybe we can expand on the reason for using Python or when to stick with R?

Comment thread03-intro-to-python.Rmd Outdated
Comment thread03-intro-to-python.Rmd Outdated
Comment thread03-intro-to-python.Rmd Outdated
Comment thread03-intro-to-python.Rmd Outdated
Comment thread03-intro-to-python.Rmd
Comment thread03-intro-to-python.Rmd Outdated
Comment thread03-intro-to-python.Rmd Outdated
```


### Classes and Object Oriented Programming (OOP)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add something here about why OOP is useful or interesting, e.g., "co-locating" data and methods? Inheritance we should maybe save for a later chapter?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if talking about OOP topics like inheritance or encapsulation is too advanced for the students. I'll leave this up to @cansavvy

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to introduce the students to this concept, but I'm not sure if we want to do it so soon. This should probably be its own chapter.

OOP is something a bit foreign for R users and something R can't do very well. So I would add that to the start comparison part at the beginning of this chapter in very general terms (i'll put a suggestion for how to do that) but then we can dive into the details later

Comment thread03-intro-to-python.Rmd
Comment thread03-intro-to-python.Rmd Outdated
Comment threadpython.Rproj Outdated
@@ -0,0 +1,18 @@
Version: 1.0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this workspace file be committed or listed in .gitignore?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have the Markdown Notebook infrastructure set up, we can delete this file. I mainly created this file to work in RStudio.

@howardbaik

Copy link
Copy Markdown
ContributorAuthor

This looks great! I've left a few specific comments inline. A few additional questions:

  • I couldn't see the two png files being referenced in the markdown. Should they be removed?
  • Maybe we can expand on the reason for using Python or when to stick with R?
  • I was using VSCode for the writing part, but since have switched to RStudio as my IDE and created a .Rproj file to facilitate my workflow. I'll look into those two png files and see if they are necessary!
  • 100%. I can incorporate the knowledge from this video into this chapter.

howardbaikand others added 4 commits February 13, 2024 10:52
Co-authored-by: Till Hoffmann <tillahoffmann@gmail.com>
Co-authored-by: Till Hoffmann <tillahoffmann@gmail.com>
@howardbaik

howardbaik commented Feb 13, 2024

Copy link
Copy Markdown
ContributorAuthor

NOTE to myself

To convert .Rmd to .md:

Get rid of the curly brackets around the python.
Delete the R from .Rmd to make it a .md file
Delete all knitr code chunks
Replace the ottrpal image part with Till's syntax for including images.

To render locally: make "name_of_document" .ipynb.html

@cansavvycansavvy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great start @howardbaek !

Comment thread03-intro-to-python.Rmd Outdated
Comment thread03-intro-to-python.Rmd Outdated
Comment thread03-intro-to-python.Rmd Outdated
Comment thread03-intro-to-python.Rmd Outdated
Comment thread03-intro-to-python.Rmd Outdated
Comment thread03-intro-to-python.Rmd Outdated
```


### Classes and Object Oriented Programming (OOP)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to introduce the students to this concept, but I'm not sure if we want to do it so soon. This should probably be its own chapter.

OOP is something a bit foreign for R users and something R can't do very well. So I would add that to the start comparison part at the beginning of this chapter in very general terms (i'll put a suggestion for how to do that) but then we can dive into the details later

Comment thread03-intro-to-python.Rmd
Comment thread03-intro-to-python.Rmd Outdated

### Classes and Object Oriented Programming (OOP)

In R, the most widely used unit of composition for code is functions, and in Python, it is classes. Classes are how you organize and find methods in Python. This approach to code composition is called object oriented programming (OOP). Let's dive in the details of OOP.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put OOP in its own chapter. @howardbaek Can you make a new branch and put OOP in its own chapter and we can dive into this more on that branch/PR?

Comment thread03-intro-to-python.Rmd Outdated

An object is any entity that you want to store and process data about. Each object is an instance of a class in the computer's memory. A class is a template for creating objects. Creating an object from a class is called instantiation. It has properties and methods (functions for the class).

For example, we could have a class called Person. The properties of this class are what describe this Person class:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like these kinds of toy examples! Excellent!

Comment thread03-intro-to-python.Rmd
Co-authored-by: Candace Savonen <cansav09@gmail.com>
@howardbaikhowardbaik mentioned this pull request Apr 15, 2024
Open
@howardbaik

Copy link
Copy Markdown
ContributorAuthor

@tillahoffmann I've made more changes to 03-intro-to-python.md and committed that file. However, I'm not sure where these files came from:

  • .ipynb_checkpoints/03-intro-to-python-checkpoint.md
  • docs/03-intro-to-python.md
  • 02-chapter_of_course_files/figure-html/unnamed-chunk-2-1.png
  • 02-chapter_of_course_files/figure-html/unnamed-chunk-3-1.png

Is it safe to delete these files?

@tillahoffmann

Copy link
Copy Markdown
Collaborator
  • Let's delete the .ipynb_checkpoints directory and add it to the .gitignore.
  • Let's delete the python.Rproj and add *.Rproj to the .gitignore.
  • Regarding the docs/03-intro-to-python.md, I'm not sure how that was created. Maybe @cansavvy has an idea?
  • Regarding the _bookdown_files, I'll also defer to @cansavvy.

@cansavvy

Copy link
Copy Markdown
Collaborator
  • Let's delete the .ipynb_checkpoints directory and add it to the .gitignore.
  • Let's delete the python.Rproj and add *.Rproj to the .gitignore.
  • Regarding the docs/03-intro-to-python.md, I'm not sure how that was created. Maybe @cansavvy has an idea?
  • Regarding the _bookdown_files, I'll also defer to @cansavvy.
  • Totally agree on getting rid of the .ipynb_checkpoints files and adding to the gitignore.
  • The .Rproj file is not something automatically generated (I don't think) so should just be able to delete and that will be it.
  • docs and _bookdown_files are what are ultimately published from for the website.

@github-actions

github-actionsBot commented Apr 17, 2024

Copy link
Copy Markdown

No broken url errors! 🎉
Comment updated at 2024-07-09-18:10:33 with changes from bab84da

@howardbaik

Copy link
Copy Markdown
ContributorAuthor

Following changes have been made:

  • Delete .ipynb_checkpoints/ and add it to the .gitignore
  • Delete python.Rproj and add to .gitignore

@github-actions

github-actionsBot commented Jul 9, 2024

Copy link
Copy Markdown

Re-rendered previews from the latest commit:

Updated at 2024-07-09 with changes from 0d537dc

@cansavvy
cansavvy merged commit e3e4cd2 into mainJul 9, 2024
@cansavvy
cansavvy deleted the howardbaek/r-vs-python branch July 9, 2024 18:14
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

R vs Python Chapter

3 participants

@howardbaik@tillahoffmann@cansavvy