How to plot a boxplot of single column using plotnine in python without any grouping? - plotnine

This is mt cars data-set.
I want to plot the box-plot of mpg column, we also have to specify x aesthetic if we are not it is showing error
(
ggplot(cars,aes(y='mpg',x=))+geom_boxplot()
)

You can supply a dummy value for x:
( ggplot(mtcars,aes(y='mpg',x=0))+geom_boxplot() )

Related

How to dynamically normalize a value based on a match from another column in Tableau

Hello I am a new user of stackoverflow, so apologies if I don't follow typical conventions.
sample
Control
Value
Normalized Value (Relative to Control)
a
e
5.5
5.5/5.7
b
e
8.3
8.3/5.7
c
f
6.6
6.6/7.7
d
f
9.9
9.9/7.7
e
5.7
f
7.7
I have an example table (shown above) where I would like Tableau to automatically calculate the last column (Normalized Value) using the data from previous columns.
How do I make the normalization dynamic to the appropriate control value?
In a simpler case, I was able to normalize all the values to a single control, however this is NOT dynamic. Below is how I use LOD to normalize to "e".
[Value]/{fixed:avg(if [sample]='e' then [Value] end )}
But this is not what I want, because sometimes I need to normalize to "e" and other times it is "f".

using SWITCH() Formula in Google Sheets using hash-map

In my Google Sheet table, I use SWITCH command to convert a cell from coin symbol -> into coin value.
what I currently do:
=SWITCH(D660,"₪","ILS","$","USD","Ft","HUF","€","EUR","лв","BGN","£","EGP")
this will convert cell D660 from coin symbol (₪/$/Ft/€/лв/£) -> into coin name
here's an example of my data:
where in column E I have the equation above.
what I want to do:
I want to a more generic way, where I have a "hash-map" table in my Settings tab which contains the following table:
coin_symbol
coin_name
₪
ILS
$
USD
Ft
HUF
€
EUR
лв
BGN
£
EGP
and now I want the =SWITCH(D660,...) to use the table instead of hard coding inserting the conversion table
.
I'm struggling on this one, I tried stuffs like
=SWITCH(D660,A1:A10,B1:B10) or involving ARRAYFORMULA somewhere but nothing worked.
anyone have a suggestion how to implement that?
You can use VLOOKUP()
In table with the coins symbols and value as you described ( where symbols is column A and name column B)
=VLOOKUP([SYMBOL];[A1:B6];2;FALSE)
Where:
Symbol is the symbol you want to replace ( you can use cell reference );
A1:B6 is the table you want to look in;
2 is the column in wich you take the value;
False as the values are not ordered by a number, just use false.
/!\ depending on your locatioon the ; in my formula might have to be replaced by ,
Here's an example you could use

How to generate a series of repeated data based on its specified quantity in Google Sheets?

I would like to generate a series of repeated data based on its specified quantity in Google Sheets.
For example, in my first sheet, I have the following data:
In the second sheet, I would like it to display a series of data repeated item based on its "Quantity" like this:
Any idea on how to do this?
try:
=ARRAYFORMULA(TRANSPOSE(SPLIT(CONCATENATE(REPT(A:A&"♦", B:B)), "♦")))
or:
=TRANSPOSE(SPLIT(JOIN(",", ARRAYFORMULA(REPT(SPLIT(
INDIRECT("A1:A"&COUNTA(A1:A)), ",")&",",
INDIRECT("B1:B"&COUNTA(B1:B))))), ","))
Assuming your data is in A1
={"Items Repeated";arrayformula(transpose(split(join("☺",rept(A2:A5&"☺",B2:B5)),"☺")))}
Try this:
=transpose
(
arrayformula
(
split
(
join
(
"✪",rept(filter(C33:C,C33:C<>"") & "✪",filter(D33:D,C33:C<>""))
),
"✪"
)
)
)

How to use an arrayformula to calculate balance on each line

I have a Google sheet which has two columns. Column F has a numeric value in it and I want column G to contain the value of column G in the previous row plus the value of column F in the current row, basically a running total.
I'm trying to use an array formula to do the calculation and it works for the first couple of rows but after that Column G contains the same value as Column F.
The formula I'm using is:
=arrayformula(F3:F10+G2:G9)
What am I doing wrong?
In general, nothing should not use its own output as input. Iterative calculation would be required, and that's a trap-laden path to be avoided whenever there's an established alternative. In this case, the usual approach to a Running Total is MMULT and some garnishing.
If your data starts in F2, put this in G2:
=ArrayFormula(IF(F2:F10,
MMULT(
TRANSPOSE((ROW(F2:F10)<=TRANSPOSE(ROW(F2:F10)))*F2:F10),
SIGN(F2:F10)),
IFERROR(1/0)
))
Or, slightly more opaque, but able to cope with negative values:
=ArrayFormula(IF(F2:F10,
MMULT(
TRANSPOSE((ROW(F2:F10)<=TRANSPOSE(ROW(F2:F10)))*F2:F10),
IF({F2:F10}<>0,1,0)),
IFERROR(1/0)
))
a slight alternative would be:
=ARRAYFORMULA(IF(F2:F;
MMULT(TRANSPOSE((ROW(F2:F)<=TRANSPOSE(ROW(F2:F)))*F2:F);
SIGN(F2:F)^2); IFERROR(1/0)))

Converting arithmetic formula from string to a values

I have a table in which all entries are in form of arithmetic formulas (i.e. '0.51 + 2.50 + 3.50').
In this table all columns are of type varchar. The table has many columns like this.
I want to calculate formula within a function and use it for some other calculation, but my problem is "EXEC" can not be used in side function and i can not take function within Stored procedure.
So, Any suggestions on how to achieve this?
Disclaimer: I'm the owner of the project Eval SQL.NET
Instead to create your own SQL CLR as suggested, you can use an existing one which allow you to esily write C# syntax in T-SQL.
-- SELECT 6.51
SELECT SQLNET::New('0.51 + 2.50 + 3.50').Eval()
You can even use column as formula and parameter
-- Evaluate dynamically expression in T-SQL
DECLARE #tableFormula TABLE (
Formula VARCHAR(255), X INT, Y INT, Z INT
)
INSERT INTO #tableFormula VALUES ('x+y*z', 1, 2, 3 ),
('(x+y)*z', 1, 2, 3 )
-- SELECT 7
-- SELECT 9
SELECT SQLNET::New(Formula)
.Val('x', X)
.Val('y', Y)
.Val('z', Z).EvalInt()
FROM #tableFormula
Documentation: Dynamically evaluating arithmetic operation in T-SQL

Resources