Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Aligning data
#6
# you can do this instead with indexing
Hey! Thank you so much for your helpful response. When I copy and run this code, though, I get the following:
('sample002c.com', -18, 'sample002b.com', -16, 'sample001a.com', -12)
('sample004c.com', -22, 'sample003b.com', -16, 'sample002a.com', -14)
('sample004b.com', -20, 'sample003a.com', -16, 'sample005c.com', -16)
('sample004a.com', -18, 'sample005b.com', -14)
('sample005a.com', -12)
Perhaps I have messed something up. It looks a bit jumbled. So far, I've been importing the data via excel as a data frame. I am a little unclear as to what the zip function is doing in this loop. I think I'm supposed to be "zipping" columns instead of rows maybe? So far I have been importing this data as a dataframe and then modifying it to have merged columns, each containing of the name married to the value:
A B C
0 (sample0001a.com, -12) (sample0002b.com, -16.0) (sample0002c.com, -18.0)
1 (sample0002a.com, -14) (sample0002b.com, -16.0) (sample0004c.com, -22.0)
2 (sample0003a.com, -16) (sample0003b.com, -20.0) (sample0005c.com, -16.0)
3 (sample0004a.com, -18) (sample0004b.com, -14.0) (nan, nan)
4 (sample0005a.com, -12) (nan, nan) (nan, nan

The structure of the function you posted seems helpful, but I think my lack of understanding is preventing me from effectively modifying it.

Agh I realized I posted my question wrong at the very beginning.I am so sorry to anyone involved.
I'm trying to align the sample numbers like so:
sample002a.com, -14, sample002b.com, -16, sample002c.com, -18
sample004a.com, -18, sample004b.com, -20 sample004c.com, -22
sample005a.com, -12, sample005b.com, -14, sample005c.com, -16
sample003a.com, -16, sample003b.com, -16
sample001a.com, -12
I have imported the data and split the string of the sample name into an integer and a letter but am still struggling to systematically move cells based on the integer similarity.
Reply


Messages In This Thread
Aligning data - by gat - Jun-17-2019, 03:37 PM
RE: Aligning data (sorry) :( - by DeaD_EyE - Jun-17-2019, 04:14 PM
RE: Aligning data (sorry) :( - by gat - Jun-18-2019, 09:22 PM
RE: Aligning data (sorry) :( - by Ecniv - Jun-17-2019, 06:25 PM
RE: Aligning data (sorry) :( - by gat - Jun-18-2019, 06:34 PM
RE: Aligning data (sorry) :( - by Ecniv - Jun-18-2019, 07:07 PM
RE: Aligning data - by vindo - Jun-19-2019, 02:12 PM
RE: Aligning data - by gat - Jun-19-2019, 02:49 PM
RE: Aligning data - by Ecniv - Jun-20-2019, 03:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Aligning excel data gat 1 2,244 Jun-17-2019, 07:05 PM
Last Post: michalmonday

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020