Summing values then adding to table and keep summing? PHP
Date : March 29 2020, 07:55 AM
I wish this helpful for you Basically what I'm trying to accomplish is this: I have a page that asks for , Try this: $amounts = array();
$startAmount = 1000000; // not given in your code?
for ($i = 0; $i < $ytd; ++$i)
{
$startAmount = $startAmount * $interestRate + $startAmount;
$amounts[] = array( "year" => $i+1,
"amount" => $startAmount,
"interest" => $interestRate
};
}
foreach ( $amounts as $amount )
{
?>
<tr>
<td><?php echo $amount['year']; ?>
<td><?php echo $amount['interest']; ?>
<td><?php echo $amount['amount']; ?>
</tr>
<?php
}
|
Summing Values based on Hour and Month and Re-arranging Summed Time Series
Tag : r , By : user147496
Date : March 29 2020, 07:55 AM
this will help I am trying to aggregate (sum) values across months and hours and re-arrange the summed data so that hour and month are on different "axes". I would like the hour to be column headers and the month to be row headers with summed values in each cell. Here's what I mean, through a dummy data example (obviously 12 months are present and 24 hours in the real data): , We can use xtabs to create a contingency table xtabs(Value~Month+Hour)
|
SSRS: Adding a line to a stacked bar column chart summing values based on series
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , If you can edit your dataset to pass in the required values then it's fairly simple. Lets say we now have 5 Status values; Enrolled, Suppressed, New, Opportunity and NewEnrol. NewEnrol will contain the sum of the New and Enrolled values. Month Status StatusCount
'Apr 2017' Enrolled 160
'Apr 2017' Suppressed 40
'Apr 2017' New 15
'Apr 2017' Opportunity 270
'Apr 2017' NewEnrol 175
=IIF(Fields!Status.Value = "NewEnrol", SUM(Fields!StatusCount.Value), nothing)
=IIF(Fields!Status.Value <> "NewEnrol", SUM(Fields!StatusCount.Value), nothing)
|
adding values to month columns based on date value
Tag : python , By : user152423
Date : March 29 2020, 07:55 AM
hop of those help? Use period_range in list comprehension for list of dictionaries for matched values, create DataFrame, replace missing values to 0 and DataFrame.join to original: L = [dict.fromkeys(pd.period_range(s, e), 1)
for s, e in zip(df['signupmonth'], df['cancelmonth'])]
rng = pd.period_range('2017-01', '2018-12', freq='m')
df1 = pd.DataFrame(L, index=df.index, columns=rng).fillna(0).astype(int)
print (df1)
2017-01 2017-02 2017-03 2017-04 2017-05 2017-06 2017-07 2017-08 \
0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1
2017-09 2017-10 ... 2018-03 2018-04 2018-05 2018-06 2018-07 \
0 0 0 ... 1 1 1 0 0
1 1 1 ... 1 0 0 0 0
2018-08 2018-09 2018-10 2018-11 2018-12
0 0 0 0 0 0
1 0 0 0 0 0
[2 rows x 24 columns]
df = df.join(df1)
#print (df)
|
Adding column with boolean values, based on a month in pandas data frame
Tag : python , By : Pepe Araya
Date : March 29 2020, 07:55 AM
may help you . You can use datetime.dt.stftime with %b formatter, get_dummies, reindex and join back onto original DataFrame: # Example setup
columns = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov"]
df = pd.DataFrame({'TIME': ['2020-01', '2019-12', '2019-11', '2019-10', '2019-09']})
df.join(pd.to_datetime(df['TIME']).dt.strftime('%b')
.str.get_dummies()
.reindex(columns=columns, fill_value=0))
TIME Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov
0 2020-01 1 0 0 0 0 0 0 0 0 0 0
1 2019-12 0 0 0 0 0 0 0 0 0 0 0
2 2019-11 0 0 0 0 0 0 0 0 0 0 1
3 2019-10 0 0 0 0 0 0 0 0 0 1 0
4 2019-09 0 0 0 0 0 0 0 0 1 0 0
import datetime as dt
columns = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov"]
df = pd.DataFrame({'TIME': ['2020-01', '2019-12', '2019-11', '2019-10', '2019-09']})
for c in columns:
for i, t in df['TIME'].iteritems():
if dt.datetime.strptime(t, '%Y-%m').strftime('%b') == c:
df.loc[i, c] = 1
else:
df.loc[i, c] = 0
|