column with a fixed number of numbers Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How do I check if a string is a number (float)?How do I get the number of elements in a list in Python?Selecting multiple columns in a pandas dataframeRenaming columns in pandasAdding new column to existing DataFrame in Python pandasHow to change the order of DataFrame columns?Delete column from pandas DataFrame by column nameSelect rows from a DataFrame based on values in a column in pandasGet list from pandas DataFrame column headersCounting unique values in columns - pandas Python
Do I really need to have a message in a novel to appeal to readers?
How to write capital alpha?
What order were files/directories output in dir?
Is it possible for SQL statements to execute concurrently within a single session in SQL Server?
Google .dev domain strangely redirects to https
AppleTVs create a chatty alternate WiFi network
What would you call this weird metallic apparatus that allows you to lift people?
What does this say in Elvish?
What does it mean that physics no longer uses mechanical models to describe phenomena?
If the probability of a dog barking one or more times in a given hour is 84%, then what is the probability of a dog barking in 30 minutes?
How could we fake a moon landing now?
How does light 'choose' between wave and particle behaviour?
One-one communication
Why can't I install Tomboy in Ubuntu Mate 19.04?
What's the difference between the capability remove_users and delete_users?
macOS: Name for app shortcut screen found by pinching with thumb and three fingers
Misunderstanding of Sylow theory
What does 丫 mean? 丫是什么意思?
Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?
Why is it faster to reheat something than it is to cook it?
Why are vacuum tubes still used in amateur radios?
How can I set the aperture on my DSLR when it's attached to a telescope instead of a lens?
An adverb for when you're not exaggerating
Do wooden building fires get hotter than 600°C?
column with a fixed number of numbers
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How do I check if a string is a number (float)?How do I get the number of elements in a list in Python?Selecting multiple columns in a pandas dataframeRenaming columns in pandasAdding new column to existing DataFrame in Python pandasHow to change the order of DataFrame columns?Delete column from pandas DataFrame by column nameSelect rows from a DataFrame based on values in a column in pandasGet list from pandas DataFrame column headersCounting unique values in columns - pandas Python
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm trying to automate an excel work using pandas.
I have a given database with a column 'reference', this column should have 2 numbers (example: 25, 53, 45...).
I need to have all the rows in the column with two numbers but references like 1, 2, 3, 4 until 9 are only 1 number.
Is there a function I can add in order to transform the whole rows of this column to two numbers reference?
I have already tried the if-statement but it didn't give any result.
sorry for my English, I hope I made myself understood :)
import pandas as pd
df = pd.read_excel('file.xlsx')
reference# #column 2# #column 3
1 Yellow 7474
10 brown 8220
43 white 29374
45 black 993
2 brown 9220
5 brown 2929
39 black 3683
df.set_index('reference', inplace=True)
.....
My output has to be like this :
reference# #column 2# #column 3
01 Yellow 7474
10 brown 8220
43 white 29374
45 black 993
02 brown 9220
05 brown 2929
39 black 3683
python excel pandas character minimum
add a comment |
I'm trying to automate an excel work using pandas.
I have a given database with a column 'reference', this column should have 2 numbers (example: 25, 53, 45...).
I need to have all the rows in the column with two numbers but references like 1, 2, 3, 4 until 9 are only 1 number.
Is there a function I can add in order to transform the whole rows of this column to two numbers reference?
I have already tried the if-statement but it didn't give any result.
sorry for my English, I hope I made myself understood :)
import pandas as pd
df = pd.read_excel('file.xlsx')
reference# #column 2# #column 3
1 Yellow 7474
10 brown 8220
43 white 29374
45 black 993
2 brown 9220
5 brown 2929
39 black 3683
df.set_index('reference', inplace=True)
.....
My output has to be like this :
reference# #column 2# #column 3
01 Yellow 7474
10 brown 8220
43 white 29374
45 black 993
02 brown 9220
05 brown 2929
39 black 3683
python excel pandas character minimum
Welcome to StackOverflow. Unfortunately its not very clear what you are asking. As you are using Pandas, I assume your data is in CSV format. Could you share an example section of your data? It may also help to share an example of the output you would like to achieve.
– 4Oh4
Mar 8 at 22:48
add a comment |
I'm trying to automate an excel work using pandas.
I have a given database with a column 'reference', this column should have 2 numbers (example: 25, 53, 45...).
I need to have all the rows in the column with two numbers but references like 1, 2, 3, 4 until 9 are only 1 number.
Is there a function I can add in order to transform the whole rows of this column to two numbers reference?
I have already tried the if-statement but it didn't give any result.
sorry for my English, I hope I made myself understood :)
import pandas as pd
df = pd.read_excel('file.xlsx')
reference# #column 2# #column 3
1 Yellow 7474
10 brown 8220
43 white 29374
45 black 993
2 brown 9220
5 brown 2929
39 black 3683
df.set_index('reference', inplace=True)
.....
My output has to be like this :
reference# #column 2# #column 3
01 Yellow 7474
10 brown 8220
43 white 29374
45 black 993
02 brown 9220
05 brown 2929
39 black 3683
python excel pandas character minimum
I'm trying to automate an excel work using pandas.
I have a given database with a column 'reference', this column should have 2 numbers (example: 25, 53, 45...).
I need to have all the rows in the column with two numbers but references like 1, 2, 3, 4 until 9 are only 1 number.
Is there a function I can add in order to transform the whole rows of this column to two numbers reference?
I have already tried the if-statement but it didn't give any result.
sorry for my English, I hope I made myself understood :)
import pandas as pd
df = pd.read_excel('file.xlsx')
reference# #column 2# #column 3
1 Yellow 7474
10 brown 8220
43 white 29374
45 black 993
2 brown 9220
5 brown 2929
39 black 3683
df.set_index('reference', inplace=True)
.....
My output has to be like this :
reference# #column 2# #column 3
01 Yellow 7474
10 brown 8220
43 white 29374
45 black 993
02 brown 9220
05 brown 2929
39 black 3683
python excel pandas character minimum
python excel pandas character minimum
edited Mar 8 at 23:25
ZAKARIA
asked Mar 8 at 22:11
ZAKARIAZAKARIA
32
32
Welcome to StackOverflow. Unfortunately its not very clear what you are asking. As you are using Pandas, I assume your data is in CSV format. Could you share an example section of your data? It may also help to share an example of the output you would like to achieve.
– 4Oh4
Mar 8 at 22:48
add a comment |
Welcome to StackOverflow. Unfortunately its not very clear what you are asking. As you are using Pandas, I assume your data is in CSV format. Could you share an example section of your data? It may also help to share an example of the output you would like to achieve.
– 4Oh4
Mar 8 at 22:48
Welcome to StackOverflow. Unfortunately its not very clear what you are asking. As you are using Pandas, I assume your data is in CSV format. Could you share an example section of your data? It may also help to share an example of the output you would like to achieve.
– 4Oh4
Mar 8 at 22:48
Welcome to StackOverflow. Unfortunately its not very clear what you are asking. As you are using Pandas, I assume your data is in CSV format. Could you share an example section of your data? It may also help to share an example of the output you would like to achieve.
– 4Oh4
Mar 8 at 22:48
add a comment |
1 Answer
1
active
oldest
votes
Is it possible for you to post a data sample of what you have and what you are looking for?
To read in your excel document use:
df = pd.read_excel('excel_doc.xlsx')
In general, if you have a 'reference' column in pandas we would call this the 'index' column.
You can set the index by going:
df.set_index('reference_column',inplace=True)
If you are trying to add a zero in front of the numbers (less than 9) you need to turn it into a text string. You can then use zfill to 'fill' in the 0 for the numbers less than 2 digits.
df['column_of_numbers'].str.zfill(2)
Good luck!
Do I need to turn it to a text string in the excel file ? or using python ?
– ZAKARIA
Mar 8 at 23:01
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%2f55071712%2fcolumn-with-a-fixed-number-of-numbers%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
Is it possible for you to post a data sample of what you have and what you are looking for?
To read in your excel document use:
df = pd.read_excel('excel_doc.xlsx')
In general, if you have a 'reference' column in pandas we would call this the 'index' column.
You can set the index by going:
df.set_index('reference_column',inplace=True)
If you are trying to add a zero in front of the numbers (less than 9) you need to turn it into a text string. You can then use zfill to 'fill' in the 0 for the numbers less than 2 digits.
df['column_of_numbers'].str.zfill(2)
Good luck!
Do I need to turn it to a text string in the excel file ? or using python ?
– ZAKARIA
Mar 8 at 23:01
add a comment |
Is it possible for you to post a data sample of what you have and what you are looking for?
To read in your excel document use:
df = pd.read_excel('excel_doc.xlsx')
In general, if you have a 'reference' column in pandas we would call this the 'index' column.
You can set the index by going:
df.set_index('reference_column',inplace=True)
If you are trying to add a zero in front of the numbers (less than 9) you need to turn it into a text string. You can then use zfill to 'fill' in the 0 for the numbers less than 2 digits.
df['column_of_numbers'].str.zfill(2)
Good luck!
Do I need to turn it to a text string in the excel file ? or using python ?
– ZAKARIA
Mar 8 at 23:01
add a comment |
Is it possible for you to post a data sample of what you have and what you are looking for?
To read in your excel document use:
df = pd.read_excel('excel_doc.xlsx')
In general, if you have a 'reference' column in pandas we would call this the 'index' column.
You can set the index by going:
df.set_index('reference_column',inplace=True)
If you are trying to add a zero in front of the numbers (less than 9) you need to turn it into a text string. You can then use zfill to 'fill' in the 0 for the numbers less than 2 digits.
df['column_of_numbers'].str.zfill(2)
Good luck!
Is it possible for you to post a data sample of what you have and what you are looking for?
To read in your excel document use:
df = pd.read_excel('excel_doc.xlsx')
In general, if you have a 'reference' column in pandas we would call this the 'index' column.
You can set the index by going:
df.set_index('reference_column',inplace=True)
If you are trying to add a zero in front of the numbers (less than 9) you need to turn it into a text string. You can then use zfill to 'fill' in the 0 for the numbers less than 2 digits.
df['column_of_numbers'].str.zfill(2)
Good luck!
answered Mar 8 at 22:24
mikemike
7726
7726
Do I need to turn it to a text string in the excel file ? or using python ?
– ZAKARIA
Mar 8 at 23:01
add a comment |
Do I need to turn it to a text string in the excel file ? or using python ?
– ZAKARIA
Mar 8 at 23:01
Do I need to turn it to a text string in the excel file ? or using python ?
– ZAKARIA
Mar 8 at 23:01
Do I need to turn it to a text string in the excel file ? or using python ?
– ZAKARIA
Mar 8 at 23:01
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%2f55071712%2fcolumn-with-a-fixed-number-of-numbers%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
Welcome to StackOverflow. Unfortunately its not very clear what you are asking. As you are using Pandas, I assume your data is in CSV format. Could you share an example section of your data? It may also help to share an example of the output you would like to achieve.
– 4Oh4
Mar 8 at 22:48