I have the following XML file that I am parsing with xsltproc:
Fig1 sheet1.xml
<data>1</data>
<data>2</data>
<data>3</data>
<data>4</data>
At certain times I will be receiving data like this
Fig2 sheet2.xml
<data>1</data>
<data>3</data>
<data>4</data>
Currently the data is displayed like this:
a - 1
b - 2
c - 3
d - 4
But with figure 2's data i would get this:
a - 1
b - 2
c - 3
d -
And I want to output data like this:
a - 1
b - NOT EXISTING
c - 3
d - 4
I hope my description of the problem is clear. If you need me to provide more information on my issue - let me know. Thanks for any help you can provide. I am a beginner so please provide solutions that you think I could implement without too much complication based on the description of my problem.
I've decided to use a recursive template to solve this.
Related
I have problems getting the data in separate rows. At the moment all my data per column is in one cell. I really would appreciate your support!
the column header is "Dealer" and it is showing one value below like this:
|Dealer|
|:---- |
|['Automobiles', 'Garage Benz', 'Cencini SA']|
I would like to get three rows out of this:
Row
Dealer
1
'Automobiles'
2
'Garage Benz'
3
'Cencini SA'
4
....
5
....
...
...
what would be the easiest way to achieve this?
Thanks for your support, as I am totally new to pandas!
The easiest way is to convert your data into a dict like data:
x = {'Dealer':['Automobiles', 'Garage Benz', 'Cencini SA']}
Then
x = pd.DataFrame(x)
I have a dataframe that looks like this, where the "Date" is set as the index
A B C D E
Date
1999-01-01 1 2 3 4 5
1999-01-02 1 2 3 4 5
1999-01-03 1 2 3 4 5
1999-01-04 1 2 3 4 5
I'm trying to compare the percent difference between two pairs of dates. I think I can do the first bit:
start_1 = "1999-01-02"
end_1 = "1999-01-03"
start_2 = "1999-01-03"
end_2 = "1999-01-04"
Obs_1 = df.loc[end_1] / df.loc[start_1] -1
Obs_2 = df.loc[end_2] / df.loc[start_2] -1
The output I get from - eg Obs_1 looks like this:
A 0.011197
B 0.007933
C 0.012850
D 0.016678
E 0.007330
dtype: float64
I'm looking to build some correlations between Obs_1 and Obs_2. I think I need to create a new dataframe with the labels A-E as one column (or as the index), and then the data series from Obs_1 and Obs_2 as adjacent columns.
But I'm struggling! I can't 'see' what Obs_1 and Obs_2 'are' - have I created a list? A series? How can I tell? What would be the best way of combining the two into a single dataframe...say df_1.
I'm sure the answer is staring me in the face but I'm going mental trying to figure it out...and because I'm not quite sure what Obs_1 and Obs_2 'are', it's hard to search the SO archive to help me.
Thanks in advance
I'm in BO 4.1 using a crosstab table. It is summary data based off specific detail information. Example:
Area-Days Late-Order #-Reason
1 - 5 - 12345-Lost
1 - 2 - 843254 - Lost
2 - 4 - 7532384 - Lost
1 - 7 - 12353 - Not home
So the output would be
Area 1 Area 2
Lost 2 1
Not home 1 0
Now for the conditional formatting part, I want it to highlight the Area 1 Lost cell as red because two of the orders are greater than 3 days late.
For whatever reason it seems to not be doing it because it's getting hung up line item 2 because that one is less than 3 days late.
Thank you!
I cheated and created a new object and then summed and did an if statement. Thanks for looking at this.
I have a game tree (economics) structured in a dataframe like this:
Node - Parent Node
b - a
c - a
d - b
e - b
f - b
g - c
h - d
i.e. the uppermost node in the tree is a which leads to b and c. b in tun leads to d, e, f and c leads to g. and finally node d leads to h. I want to create an additional column which tells me the level at which the node occurs, i.e., I want an output which is something like this:
Node - Parent Node - Level
b - a - 1
c - a - 1
d - b - 2
e - b - 2
f - b - 2
g - c - 2
h - d - 3
How do I do this?
Moreover, if the data is not organised and is random that is the rows are not ordered the way I have shown (but it always has information on what the parent node is of a specific node), is their a way of solving the same problem and assigning the level of the node?
I know this might be super simple but I am new to Python and I didn't know how to search for this specifically.
Thanks in advance!
If you always start at your root, and ordered, you just travel down your tree and add a level when you visit a new child node.
If its not ordered i guess you could travel backwards and count the steps until you hit the root.
You'll probably need some recursive funtion to traverse around the tree.
I have a data set with 30 columns and multiple rows (some cells have no data). I would like to be able to facet the columns in groups.
1 2 3 4...
Row1 A B C D
Row2 E A D F
Row3 Q A B H
Given the above data I would like the facet to retun the number of instances in a group of columns. For the first three columns I need the facet to return:
A - 3
B - 2
C - 1
D - 1
E - 1
Q - 1
I have tried to combine columns when I loaded the data but the individual data was grouped as well. This is not the desired outcome. For example:
ABC - 1
EAD - 1
QAB - 1
Thanks in advance.
I can't think of a more efficient way to do this off the top of my head, but you can do a custom facet with something like:
[ cells.["1"].value, cells.["2"].value, cells.["3"].value ]
where "1", "2", and "3" are the names of your columns. If your column names are single words, like "V1", "V2", "V3", and so on, you can also change the custom facet to something like:
[ cells.V1.value, cells.V2.value, cells.V3.value ]
With a lot of columns, this solution might be somewhat tedious though...
Did you tried to transpose all your column in one and facet on this 'master column'?
When transposing add the column name so you know from where the data comes from. The you can split your master column into 'source column' and 'data'.
You can find here the JSON code to transpose a large amount of column: http://googlerefine.blogspot.ca/2011/09/json-code-to-transpose-important-number.html
it should work for your project with a limited amount of edits.
Hope it help!