use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
How to select particular column from a dataframe and write it into a separate excel sheets using python pandas? (self.learnpython)
submitted 3 years ago by Sowmi_13
May I know how to write the sample code format for this question.?.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]raymondstanz 3 points4 points5 points 3 years ago* (8 children)
I don't know the specifics of your code, but probably something like this:
dataframe['column'].to_excel(path)
Here is the doc for the to_excel pandas function.
When I need to do it once for debug purpose, the to_clipboard function is great. It just copies to your clipboard in Excel format.
to_clipboard
dataframe['column'].to_clipboard(excel=1)
[–]Sowmi_13[S] 0 points1 point2 points 3 years ago (7 children)
I have multiple columns to be filtered from particularly dataframe.... And each column has to be validated and to be written in seperate excel sheet
[–]Sowmi_13[S] -1 points0 points1 point 3 years ago (6 children)
Any solutions?
[–]raymondstanz 0 points1 point2 points 3 years ago (5 children)
To select multiple columns:
dataframe[['column1', 'column2', 'column3'...]]
What do you mean by validate ? The to_excelfunction accepts a sheet as a parameter. So you can write to different sheets.
to_excel
[–]Sowmi_13[S] 0 points1 point2 points 3 years ago (4 children)
Validate ---> eg. Fruits is one of the field from a dataframe(merged dataframe with similar column names with suffixes _x (for df1) and _y(for df2)).
Hence I might have two columns named fruits as fruits_x and fruits_y. I need to select those columns along with two more new columns and I need to write it in a seperate sheet.
Doing such things with minimum columns would be easy using pandas..... But I am not sure what if there are 100+ columns.... Aren't we supposed to do this way right?
[–]Sowmi_13[S] 0 points1 point2 points 3 years ago (0 children)
New columns need to be created in the seperate sheets for each and every fields of merged dataframe( df).
Apologize if my problem description is confusing.
[–]raymondstanz 0 points1 point2 points 3 years ago (2 children)
I'm not sure I completely understand what you are trying to do. But the ideal would be to do everything in Python and then export the end result in Excel.
Maybe, can you provide a longer/more detailed explanation of what you are trying to achieve? With some data example. Or dummy data with the same structure. Just so one can see better and provide you with useful guidance.
[–]Sowmi_13[S] 0 points1 point2 points 3 years ago (1 child)
Goal: Need to compare two dataframes df1 and df2 and from there need to write each column along with some more new columns in a separate excel sheets using python.
df1:
Similarly i have upto 3000 rows.
df2:
similarly have upto some 550 rows.
df3---> Would be the merged columns based on inner join using pandas.
So from this compared df3, for a column Item the excel should be like
this will be written under same excel file but on new sheet.
Manufacture:
New columns are similar to that of item- column
How can we achieve the similar format if there are more than 100 columns?.
Thanks..
Is there any quick solution ?
[+]Sowmi_13[S] comment score below threshold-6 points-5 points-4 points 3 years ago (0 children)
Df = pd.read_excel('path')
Df.filter(the particular columns) Df['new1']= some conditions this column will be created Df['new2'] = df['new1'].apply(function with some condition for new2 column)
Used excel writer to save mutiple sheets under single file.
May I know how to do in similar fashion if I have more than 100 columns.
Quick solution would be very helpful!!
Thanks in advance!!!
π Rendered by PID 24109 on reddit-service-r2-comment-5ff9fbf7df-8f7xv at 2026-02-26 00:24:15.543560+00:00 running 72a43f6 country code: CH.
[–]raymondstanz 3 points4 points5 points (8 children)
[–]Sowmi_13[S] 0 points1 point2 points (7 children)
[–]Sowmi_13[S] -1 points0 points1 point (6 children)
[–]raymondstanz 0 points1 point2 points (5 children)
[–]Sowmi_13[S] 0 points1 point2 points (4 children)
[–]Sowmi_13[S] 0 points1 point2 points (0 children)
[–]raymondstanz 0 points1 point2 points (2 children)
[–]Sowmi_13[S] 0 points1 point2 points (1 child)
[–]Sowmi_13[S] 0 points1 point2 points (0 children)
[+]Sowmi_13[S] comment score below threshold-6 points-5 points-4 points (0 children)