How to use the Pandas 'sep' command in Google Colab?
So, I used Jupyter Notebook and there using the 'sep' command was pretty simple. But now I'm slowly migrating to Google Colab, and while I can find the file and build the DataFrame with 'pd.read_csv()', I can't seem to separate the columns with the 'sep = ' command!
I mounted the Drive and located the file:
import pandas as pd
from google.colab import drive
drive.mount('/content/gdrive')
with open('/content/gdrive/My Drive/wordpress/cousins.csv','r') as f:
f.read()
Then I built the Dataframe:
df = pd.read_csv('/content/gdrive/My Drive/wordpress/cousins.csv',sep=";")
The dataframe is built, but it is not separated by columns! Below is a screenshot:
Built DataFrame
Last edit: Turns out the problem was with the data I was trying to use, because it also didn't work on Jupyter. There is no problem with the 'sep' command the way it was being used!
PS: I also tried 'sep='.'' and 'sep = ','' to see if it works, and nothing.
I downloaded the data as a 'csv' table from Football-Reference, paste it on excel, saved as a csv (UTF-8), an example of the file can be found here:
Pastebin Example File
python pandas google-colaboratory
add a comment |
So, I used Jupyter Notebook and there using the 'sep' command was pretty simple. But now I'm slowly migrating to Google Colab, and while I can find the file and build the DataFrame with 'pd.read_csv()', I can't seem to separate the columns with the 'sep = ' command!
I mounted the Drive and located the file:
import pandas as pd
from google.colab import drive
drive.mount('/content/gdrive')
with open('/content/gdrive/My Drive/wordpress/cousins.csv','r') as f:
f.read()
Then I built the Dataframe:
df = pd.read_csv('/content/gdrive/My Drive/wordpress/cousins.csv',sep=";")
The dataframe is built, but it is not separated by columns! Below is a screenshot:
Built DataFrame
Last edit: Turns out the problem was with the data I was trying to use, because it also didn't work on Jupyter. There is no problem with the 'sep' command the way it was being used!
PS: I also tried 'sep='.'' and 'sep = ','' to see if it works, and nothing.
I downloaded the data as a 'csv' table from Football-Reference, paste it on excel, saved as a csv (UTF-8), an example of the file can be found here:
Pastebin Example File
python pandas google-colaboratory
How does your data looks like? Can you update that in question?
– user8864088
Nov 25 '18 at 16:21
@astro123 did just that right now!
– Marco Gemaque
Nov 25 '18 at 16:26
You should try to paste data > images.
– Anton vBR
Nov 25 '18 at 16:28
add a comment |
So, I used Jupyter Notebook and there using the 'sep' command was pretty simple. But now I'm slowly migrating to Google Colab, and while I can find the file and build the DataFrame with 'pd.read_csv()', I can't seem to separate the columns with the 'sep = ' command!
I mounted the Drive and located the file:
import pandas as pd
from google.colab import drive
drive.mount('/content/gdrive')
with open('/content/gdrive/My Drive/wordpress/cousins.csv','r') as f:
f.read()
Then I built the Dataframe:
df = pd.read_csv('/content/gdrive/My Drive/wordpress/cousins.csv',sep=";")
The dataframe is built, but it is not separated by columns! Below is a screenshot:
Built DataFrame
Last edit: Turns out the problem was with the data I was trying to use, because it also didn't work on Jupyter. There is no problem with the 'sep' command the way it was being used!
PS: I also tried 'sep='.'' and 'sep = ','' to see if it works, and nothing.
I downloaded the data as a 'csv' table from Football-Reference, paste it on excel, saved as a csv (UTF-8), an example of the file can be found here:
Pastebin Example File
python pandas google-colaboratory
So, I used Jupyter Notebook and there using the 'sep' command was pretty simple. But now I'm slowly migrating to Google Colab, and while I can find the file and build the DataFrame with 'pd.read_csv()', I can't seem to separate the columns with the 'sep = ' command!
I mounted the Drive and located the file:
import pandas as pd
from google.colab import drive
drive.mount('/content/gdrive')
with open('/content/gdrive/My Drive/wordpress/cousins.csv','r') as f:
f.read()
Then I built the Dataframe:
df = pd.read_csv('/content/gdrive/My Drive/wordpress/cousins.csv',sep=";")
The dataframe is built, but it is not separated by columns! Below is a screenshot:
Built DataFrame
Last edit: Turns out the problem was with the data I was trying to use, because it also didn't work on Jupyter. There is no problem with the 'sep' command the way it was being used!
PS: I also tried 'sep='.'' and 'sep = ','' to see if it works, and nothing.
I downloaded the data as a 'csv' table from Football-Reference, paste it on excel, saved as a csv (UTF-8), an example of the file can be found here:
Pastebin Example File
python pandas google-colaboratory
python pandas google-colaboratory
edited Nov 25 '18 at 16:42
Marco Gemaque
asked Nov 25 '18 at 16:17
Marco GemaqueMarco Gemaque
3717
3717
How does your data looks like? Can you update that in question?
– user8864088
Nov 25 '18 at 16:21
@astro123 did just that right now!
– Marco Gemaque
Nov 25 '18 at 16:26
You should try to paste data > images.
– Anton vBR
Nov 25 '18 at 16:28
add a comment |
How does your data looks like? Can you update that in question?
– user8864088
Nov 25 '18 at 16:21
@astro123 did just that right now!
– Marco Gemaque
Nov 25 '18 at 16:26
You should try to paste data > images.
– Anton vBR
Nov 25 '18 at 16:28
How does your data looks like? Can you update that in question?
– user8864088
Nov 25 '18 at 16:21
How does your data looks like? Can you update that in question?
– user8864088
Nov 25 '18 at 16:21
@astro123 did just that right now!
– Marco Gemaque
Nov 25 '18 at 16:26
@astro123 did just that right now!
– Marco Gemaque
Nov 25 '18 at 16:26
You should try to paste data > images.
– Anton vBR
Nov 25 '18 at 16:28
You should try to paste data > images.
– Anton vBR
Nov 25 '18 at 16:28
add a comment |
1 Answer
1
active
oldest
votes
This works for me:
My data:
a,b,c
5,6,7
8,9,10
You don't need sep for comma separated file.
from google.colab import drive
drive.mount('/content/drive')
import pandas as pd
# suppose I have data in my Google Drive in the file path
# GoogleColaboratory/data/so/a.csv
# The folder GoogleColaboratory is in my Google Drive.
df = pd.read_csv('drive/My Drive/GoogleColaboratory/data/so/a.csv')
df.head()
I tried the file on Jupyter as well and it also failed, so the problem is positively with the data!
– Marco Gemaque
Nov 25 '18 at 16:31
Ok, then, instead of pasting data image, it would be better if you have some sample data in the question. Open your 'cousins.csv' in a text editor, copy some lines and paste them in question. Or, you can paste your data in pastebin.com and share the link.
– user8864088
Nov 25 '18 at 16:33
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53469426%2fhow-to-use-the-pandas-sep-command-in-google-colab%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This works for me:
My data:
a,b,c
5,6,7
8,9,10
You don't need sep for comma separated file.
from google.colab import drive
drive.mount('/content/drive')
import pandas as pd
# suppose I have data in my Google Drive in the file path
# GoogleColaboratory/data/so/a.csv
# The folder GoogleColaboratory is in my Google Drive.
df = pd.read_csv('drive/My Drive/GoogleColaboratory/data/so/a.csv')
df.head()
I tried the file on Jupyter as well and it also failed, so the problem is positively with the data!
– Marco Gemaque
Nov 25 '18 at 16:31
Ok, then, instead of pasting data image, it would be better if you have some sample data in the question. Open your 'cousins.csv' in a text editor, copy some lines and paste them in question. Or, you can paste your data in pastebin.com and share the link.
– user8864088
Nov 25 '18 at 16:33
add a comment |
This works for me:
My data:
a,b,c
5,6,7
8,9,10
You don't need sep for comma separated file.
from google.colab import drive
drive.mount('/content/drive')
import pandas as pd
# suppose I have data in my Google Drive in the file path
# GoogleColaboratory/data/so/a.csv
# The folder GoogleColaboratory is in my Google Drive.
df = pd.read_csv('drive/My Drive/GoogleColaboratory/data/so/a.csv')
df.head()
I tried the file on Jupyter as well and it also failed, so the problem is positively with the data!
– Marco Gemaque
Nov 25 '18 at 16:31
Ok, then, instead of pasting data image, it would be better if you have some sample data in the question. Open your 'cousins.csv' in a text editor, copy some lines and paste them in question. Or, you can paste your data in pastebin.com and share the link.
– user8864088
Nov 25 '18 at 16:33
add a comment |
This works for me:
My data:
a,b,c
5,6,7
8,9,10
You don't need sep for comma separated file.
from google.colab import drive
drive.mount('/content/drive')
import pandas as pd
# suppose I have data in my Google Drive in the file path
# GoogleColaboratory/data/so/a.csv
# The folder GoogleColaboratory is in my Google Drive.
df = pd.read_csv('drive/My Drive/GoogleColaboratory/data/so/a.csv')
df.head()
This works for me:
My data:
a,b,c
5,6,7
8,9,10
You don't need sep for comma separated file.
from google.colab import drive
drive.mount('/content/drive')
import pandas as pd
# suppose I have data in my Google Drive in the file path
# GoogleColaboratory/data/so/a.csv
# The folder GoogleColaboratory is in my Google Drive.
df = pd.read_csv('drive/My Drive/GoogleColaboratory/data/so/a.csv')
df.head()
edited Nov 25 '18 at 16:37
answered Nov 25 '18 at 16:28
user8864088
I tried the file on Jupyter as well and it also failed, so the problem is positively with the data!
– Marco Gemaque
Nov 25 '18 at 16:31
Ok, then, instead of pasting data image, it would be better if you have some sample data in the question. Open your 'cousins.csv' in a text editor, copy some lines and paste them in question. Or, you can paste your data in pastebin.com and share the link.
– user8864088
Nov 25 '18 at 16:33
add a comment |
I tried the file on Jupyter as well and it also failed, so the problem is positively with the data!
– Marco Gemaque
Nov 25 '18 at 16:31
Ok, then, instead of pasting data image, it would be better if you have some sample data in the question. Open your 'cousins.csv' in a text editor, copy some lines and paste them in question. Or, you can paste your data in pastebin.com and share the link.
– user8864088
Nov 25 '18 at 16:33
I tried the file on Jupyter as well and it also failed, so the problem is positively with the data!
– Marco Gemaque
Nov 25 '18 at 16:31
I tried the file on Jupyter as well and it also failed, so the problem is positively with the data!
– Marco Gemaque
Nov 25 '18 at 16:31
Ok, then, instead of pasting data image, it would be better if you have some sample data in the question. Open your 'cousins.csv' in a text editor, copy some lines and paste them in question. Or, you can paste your data in pastebin.com and share the link.
– user8864088
Nov 25 '18 at 16:33
Ok, then, instead of pasting data image, it would be better if you have some sample data in the question. Open your 'cousins.csv' in a text editor, copy some lines and paste them in question. Or, you can paste your data in pastebin.com and share the link.
– user8864088
Nov 25 '18 at 16:33
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53469426%2fhow-to-use-the-pandas-sep-command-in-google-colab%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How does your data looks like? Can you update that in question?
– user8864088
Nov 25 '18 at 16:21
@astro123 did just that right now!
– Marco Gemaque
Nov 25 '18 at 16:26
You should try to paste data > images.
– Anton vBR
Nov 25 '18 at 16:28