Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PM1_prediction.ipynb Jupyter Book Cannot Load .RData #1

Open
Eli-m93 opened this issue Feb 8, 2022 · 3 comments
Open

PM1_prediction.ipynb Jupyter Book Cannot Load .RData #1

Eli-m93 opened this issue Feb 8, 2022 · 3 comments

Comments

@Eli-m93
Copy link

Eli-m93 commented Feb 8, 2022

The current code links to github's wage data which is only an RData dataset, then the code reads:

Data Analysis
Set the following file_directory to a place where you downloaded https://github.com/CausalAIBook/MetricsMLNotebooks/blob/main/PM1/wage2015_subsample_inference.rdata

file_dir = None
df = pd.read_csv(file_dir)

I found two solutions:

  1. Import RData to Pandas ready package (taken from my collab code):
!pip install pyreadr
import pyreadr
import numpy as np
import pandas as pd
temp = pyreadr.read_r('/content/wage2015_subsample_inference.Rdata')
df = temp['data']
  1. Upload a CSV
@Eli-m93 Eli-m93 changed the title PM-1 Jupyter Book Cannot Load .RData PM1_prediction.ipynb Jupyter Book Cannot Load .RData Feb 8, 2022
@Togeka
Copy link

Togeka commented Feb 8, 2022

having similar problems, where is the CSV located?

@Eli-m93
Copy link
Author

Eli-m93 commented Feb 9, 2022

having similar problems, where is the CSV located?

Hi Togeka, you can copy and paste this code into google collab to read RData into your jupyter notebook:

!pip install pyreadr
import pyreadr
import numpy as np
import pandas as pd
temp = pyreadr.read_r('/content/wage2015_subsample_inference.Rdata')
df = temp['data']

On google collab you need to literally click the folder icon on the right hand side, and manually upload the RData file onto the collab website to use it.

@KendrickQ
Copy link

Or you could transfer the rdata to csv file manually in your computer. This is the command you need to use in your local R Studio.

data = load("~/Downloads/wage2015_subsample_inference.rdata")
write.csv(data, file="~/Downloads/data.csv")

I doubt that these python notebooks haven't been checked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants