ms excel turn columns into rows - excel

I am looking for a way to take an excel spread sheet and change the columns to rows. The sheet is currently designed like this.
Employee Name Expiration 1 Expiration 2 Expiration 3 Expiration 4
John Doe
Jane Doe
What I need to do is convert it to this
Employee Name Expiration Date
John Doe 1 12-12-12
John Doe 2 12-12-12
John Doe 3 12-12-12
John Doe 4 12-12-12
Jane Doe 1 12-1-12
Jane Doe 2 12-1-12
Jane Doe 3 12-1-12
Jane Doe 4 12-1-12
I am not even sure if this is possible.

You can do this very simply with an INDEX(MATCH(),MATCH()) formula.
This screenshot should be enough to get you started:
Screenshot(1)
Let me know if you need any more info.

Related

How update a dataframe column value from second dataframe where values on two specific columns that can repeat on first match on both dataframes?

I have two dataframes with different information about a person, on the first dataframe, person's name may repeat in different rows. I want to add/update the first dataframe with data from the second dataframe where the two columns containing person's data matches on both. Here an example on what I need to accomplish:
df1:
name surname
0 john doe
1 mary doe
2 peter someone
3 mary doe
4 john another
5 paul another
df2:
name surname account_id
0 peter someone 100
1 john doe 200
2 mary doe 300
3 john another 400
I need to accomplish this:
df1:
name surname account_id
0 john doe 200
1 mary doe 300
2 peter someone 100
3 mary doe 300
4 john another 400
5 paul another <empty>
Thanks!

How do I create single cell arrays based on unique contiguous groups?

Column A identifies unique families using multiple other columns of data.
Column B is a list of individuals.
I would like Column C to contain cell arrays of these families (Shown Below).
For some reason, the MATCH formula in my attempted solution is returning the last occurrence of the match, so it does not work.
I have tried this formula (the output of this is shown in Column D in the picture):
{=OFFSET(INDEX(A:A, MATCH(A1,A:A)),0,1,COUNTIF(A:A,A1))}
A B C D
1 Tom 1 {Tom One, Sue One} Sue 1
1 Sue 1 {Tom One, Sue One} Sue 1
2 Bob 2 {Bob Two, Joan Two, John Two} John 2
2 Joan 2 {Bob Two, Joan Two, John Two} John 2
2 John 2 {Bob Two, Joan Two, John Two} John 2
3 Tom 3 {Tom Three} Tom 3
4 Joe 4 {Joe Four} Joe 4
You can use the following formula, the condition is that it is sorted baed on column A:
="{"&TEXTJOIN(",",TRUE,INDEX(B:B,MATCH(A1,A:A,0)):INDEX(B:B,MATCH(A1,A:A,1)))&"}"

How to make a request to website and download search data

I'm trying to download some car VIN data for a list of individuals. This involves making a request to a website "http://vin.place/search.php" via requests.get in python3.7.
My code looks like this:
import requests
import pandas as pd
from bs4 import BeautifulSoup
payload = {'first name':'JOHN','last name':'DOE'}
webpage_response = requests.get("http://vin.place/search.php",data = payload)
webpage = webpage_response.content
soup = BeautifulSoup(webpage,"html.parser")
results = soup.select(".search-content")
for x in results:
print(x.get_text())
Unfortunately, I am finding that results = [] instead. I suspect there is something wrong with the way that I am coding up the requests.get command. I am not sure how what the right keys should be for the website. Can anyone please help? Thanks.
The payload you have is wrong, it should be first, last. And the names in lowercase:
import requests
from bs4 import BeautifulSoup
payload = {'first':'john','last':'doe'}
webpage_response = requests.post("http://vin.place/search.php", data=payload)
webpage = webpage_response.content
soup = BeautifulSoup(webpage,"html.parser")
results = soup.select(".search-content")
for x in results:
print(x.text)
Prints:
JOHN DOE Purchase of a 2007 HONDA ACCORD
JOHN DOE Purchase of a 2007 CHRYSLER TOWN AND COUNTRY
JOHN DOE Purchase of a 2007 DODGE RAM PICKUP 2500
JOHN DOE Purchase of a 2007 DODGE RAM PICKUP 1500
JOHN DOE Purchase of a 2007 VOLKSWAGEN PASSAT
JOHN DOE Purchase of a 2007 VOLKSWAGEN JETTA
JOHN DOE Purchase of a 2007 CHRYSLER SEBRING
JOHN DOE Purchase of a 2007 DODGE RAM PICKUP 1500
JOHN DOE Purchase of a 2007 JEEP PATRIOT
JOHN DOE Purchase of a 2007 Chevrolet TrailBlazer
JOHN DOE Purchase of a 2007 FORD EDGE
JOHN DOE Purchase of a 2007 JEEP WRANGLER UNLIMITED
JOHN DOE Purchase of a 2007 DODGE RAM PICKUP 2500
JOHN DOE Purchase of a 2007 FORD MUSTANG
JOHN DOE Purchase of a 2007 JEEP WRANGLER
JOHN DOE Purchase of a 2007 CHRYSLER 300
JOHN DOE Purchase of a 2007 JEEP WRANGLER UNLIMITED
JOHN DOE Purchase of a 2007 DODGE MAGNUM
JOHN DOE Purchase of a 2007 CADILLAC ESCALADE ESV
JOHN DOE Purchase of a 2007 FORD F-150
JOHN DOE Purchase of a 2007 HONDA ACCORD
JOHN DOE Purchase of a 2007 JEEP LIBERTY
JOHN DOE Purchase of a 2007 CADILLAC ESCALADE
JOHN DOE Purchase of a 2007 DODGE RAM PICKUP 1500
JOHN DOE Purchase of a 2007 JEEP WRANGLER
looking at the form data as sent by chrome when performing the search manually, the data is: first=JOHN&last=DOE, also, the site uses POST
please try this:
import requests
import pandas as pd
from bs4 import BeautifulSoup
payload = {'first':'JOHN','last':'DOE'}
webpage_response = requests.post("http://vin.place/search.php",data = payload)
webpage = webpage_response.content
soup = BeautifulSoup(webpage,"html.parser")
results = soup.select(".search-content")
for x in results:
print(x.get_text())

Combine 2 different sheets with same data in Excel

I have the same data from different sources, both incomplete, but combined they may be less incomplete..
I have 2 files;
File #1 has; ID, Zipcode, YoB, Gender
File #2 has: Email, ID, Zipcode, Yob, Gender
The ID's in both files are the same, but #1 has some ID's that #2 hasn't, and the other way aroud.
The Email is connected to the ID. ID's are linked to the zipcode, YoB and gender. In both files are some of that info missing. E.g. File #1 and #2 both have ID 1234, only in #1 it only has a postal code, YoB but no Gender. And #2 has the zipcode and gender but no YoB.
I want to have all the information in one file;
Email, ID, YoB, Zipcode, Gender
I tried to sort both ID's alphabetically and put them next to each other and search for duplicates, but because #1 has some ID's that #2 doesnt I'm not able to combine them...
What's the best way to fix this?
By the way its about 12000 ID's from #1 and 9500 from #2
If you want a list of all the unique IDs then you could create a new sheet, copy both lots of IDs into the same column and then use Advanced Filter to copy Unique records only to another column.
Then use that column to do vlookups from the two files in the columns you require.
(I'm presuming this is a one-time job and you don't mind a bit of manual-ness)...
If on your first Sheet ("Sheet1") you have:
ID F_Name S_Name Age Favourite Cheese
1 Bob Smith 25 Brie
2 Fred Jones 29 Cheddar
3 Jeff Brown 18 Edam
4 Alice Smith 39 Mozzarella
5 Mark Jones 65 Cheddar
7 Sarah Smith 29 Mozzarella
8 Nick Jones 40 Brie
10 Betty Thompson 34 Edam
and on your second Sheet ("Sheet2") you have:
ID F_Name S_Name Age
1 Bob Smith 25
3 Jeff Brown 18
4 Alice Smith 39
5 Mark Jones 65
6 Frank Brown 44
7 Sarah Smith 29
9 Tom Brown 28
10 Betty Thompson 34
Then if you're combining them on a 3rd Sheet you need to do something like:
=IFERROR(VLOOKUP($A2,Sheet1!$A$1:$E$9,COLUMN(),FALSE),VLOOKUP($A2,Sheet2!$A$1:$E$9,COLUMN(),FALSE))
If you're trying to get to:
ID F_Name S_Name Age Favourite Cheese
1 Bob Smith 25 Brie
2 Fred Jones 29 Cheddar
3 Jeff Brown 18 Edam
4 Alice Smith 39 Mozzarella
5 Mark Jones 65 Cheddar
6 Frank Brown 44 0
7 Sarah Smith 29 Mozzarella
8 Nick Jones 40 Brie
9 Tom Brown 28 0
10 Betty Thompson 34 Edam

Conditionally assign unique values

I have data, for example:
John Doe MD 1
Ben Doe PA
Cal Doe MD 1
Drum Doe PA
Egg Doe NP
Fun Doe MD 1
So everywhere there's an MD I have an IF condition assigning the number 1. But I want to isolate and pull all the names with a 1 consecutively. Example:
John Doe
Cal Doe
Fun Doe
I know I just have to have numeric values such as: john doe-1, cal doe-2, fun doe-3.
I'm having problem with the logic if someone can help I'll appreciate it.
If your data is in three columns (starting A2) then maybe:
=IF(B2="MD",MAX(C$1:C1)+1,"")

Resources