percentage

How to calculate percent change compared to the beginning value using pandas?

落花浮王杯 提交于 2019-11-27 23:03:45
问题 I have a DataFrame and need to calculate percent change compared to the beginning of the year by companies. Is there any way to use pct_change() or other method to perform this task? Thanks! df looks like security date price IBM 1/1/2016 100 IBM 1/2/2016 102 IBM 1/3/2016 108 AAPL 1/1/2016 1000 AAPL 1/2/2016 980 AAPL 1/3/2016 1050 AAPL 1/4/2016 1070 results I want security date price change IBM 1/1/2016 100 NA IBM 1/2/2016 102 2% IBM 1/3/2016 108 8% AAPL 1/1/2016 1000 NA AAPL 1/2/2016 980 -2%

How do I print the percent sign(%) in c [duplicate]

五迷三道 提交于 2019-11-27 21:07:42
This question already has an answer here: How to escape the % (percent) sign in C's printf? 13 answers I am a beginner in C, and I was wondering why this program does not print % sign? The code is: #include<stdio.h> main() { printf("%"); getch(); } C_Intermediate_Learner Your problem is that you have to change: printf("%"); to printf("%%"); Or you could use ASCII code and write: printf("%c", 37); :) there's no explanation in this topic why to print a percentage sign one must type %% and not for example escape character with percentage - \% . from comp.lang.c FAQ list · Question 12.6 : The

Div Height in Percentage [duplicate]

ぐ巨炮叔叔 提交于 2019-11-27 19:24:21
Possible Duplicate: Percentage Height HTML 5/CSS This needs to be a simple one but I why the height specified in percentage for a div is not apply to it. For example: <div class="container"> adsf </div> CSS: .container { width:80%; height:50%; background-color:#eee; } When I change height from % to px it works perfectly. % is as valid as px but why only px works and % not. here is the jsfiddle Edit Though I missed the semicolon after 50% in original question which totally spoiled it. In fact what I intended to ask was why does the 50% does not make it consume the 50% of its container. It only

Percentage rank of matches using Levenshtein Distance matching

六月ゝ 毕业季﹏ 提交于 2019-11-27 13:04:28
问题 I am trying to match a single search term against a dictionary of possible matches using a Levenshtein distance algorithm. The algorithm returns a distance expressed as number of operations required to convert the search string into the matched string. I want to present the results in ranked percentage list of top "N" (say 10) matches. Since the search string can be longer or shorter than the individual dictionary strings, what would be an appropriate logic for expressing the distance as a

How do I calculate the percentage of a number? [closed]

耗尽温柔 提交于 2019-11-27 10:26:26
问题 I would like to calculate, in PHP, the percentage of a number. For example: $percentage = 50; $totalWidth = 350; For this example, 50% of 350 = 175 How can I do that? 回答1: $percentage = 50; $totalWidth = 350; $new_width = ($percentage / 100) * $totalWidth; 回答2: Divide $percentage by 100 and multiply to $totalWidth . Simple maths. 来源: https://stackoverflow.com/questions/10201027/how-do-i-calculate-the-percentage-of-a-number

change value to percentage of row in R [duplicate]

五迷三道 提交于 2019-11-27 07:44:46
问题 This question already has an answer here: Calculate row-wise proportions 4 answers this is my data A B C A 9 1 0 B 2 2 2 C 3 3 3 I want to get percentage of each row my expect data is A B C A 0.9 0.1 0 B 0.33 0.33 0.33 C 0.33 0.33 0.33 I made my data with 'dcast' and there is column name on A,B and C. so actually my real data is Name A B C 1 A 0.9 0.1 0 2 B 0.33 0.33 0.33 3 C 0.33 0.33 0.33 回答1: Seems a fair case for df/rowSums(df) # A B C # A 0.9000000 0.1000000 0.0000000 # B 0.3333333 0

simple calculation not working for some reason

拟墨画扇 提交于 2019-11-27 05:41:33
Alright, I'm trying to calculate the percentage of two values. This should be really simple but for some weird reason it's not working. I'm too tired/dumb to figure it out. Here's my code, it keeps returning 0, i checked the values while debugging and with FilesCompleted being 295 and TotalFilesCount being 25002 the returnvalue var is just 0, it should be 1 already. private int CalculatePercentComplete(int FilesCompleted, int TotalFilesCount) { int returnvalue = (FilesCompleted / TotalFilesCount) * 100; if (returnvalue > 100 || returnvalue < 1) return 1; else return returnvalue; } i checked

jfreechart customize piechart to show absolute values and percentages

断了今生、忘了曾经 提交于 2019-11-27 05:25:40
How can this compilable minimal code snippet example, which uses JFreeChart as plotting API, adapted in order to show both absoulte values AND percentages ? I couldn't extract this information neither from any code snippet on the internet nor from the JFreechart manual itself. The code snippet produces a pie chart showing only percentages. The absolute values in my case also matter, so i need to display them right under the percentages. Here is the code: (Note it lacks the imports) public class MyMinimalPieChartExample { public static void main(String[] args) { DefaultPieDataset dataset = new

jqGrid - format ratio field as percent value

陌路散爱 提交于 2019-11-27 05:13:31
My server code transfers some column as a ratio value, 0.0 to 1.0. I need to format and edit it as a percent. I would like to do it on JavaScript side, without modifying server-side. So if I add a custom formatter to just multiply the value by 100, display works as expected. Moreover, when I hit edit button, inline edit box also displays value as percentage. The trouble starts when I save - the value gets converted with formatter one more time , giving me things like 10000. So OK, I need symmetry here, so I create an unformatter which just divides value by 100. But that doesn't work too - now

MySQL Calculate Percentage

廉价感情. 提交于 2019-11-27 04:59:15
I have a MySQL database with 4 items: id (numerical), group_name , employees , and surveys . In my SELECT I need to calculate the percentage of 'employees' who, by the number in 'surveys', have taken the survey. This is the statement I have now: SELECT group_name, employees, surveys, COUNT( surveys ) AS test1, ((COUNT( * ) / ( SELECT COUNT( * ) FROM a_test)) * 100 ) AS percentage FROM a_test GROUP BY employees Here is the table as it stands: INSERT INTO a_test (id, group_name, employees, surveys) VALUES (1, 'Awesome Group A', '100', '0'), (2, 'Awesome Group B', '200', '190'), (3, 'Awesome