Now to just add on to our knowledge of Pandas we practiced using them a little more by making a more logical code with single script with input/output.
I think this was more focussed on object oriented programming in python. I learnt more about this as I never knew about this before and I learnt how this was different from languages like java where here we have variables like self or commands like __init__ and such. This is my code: import pandas as pd class EnergyAnalysis: def __init__(self, csv, column, column2): self.csv = pd.read_csv(csv) self.csvName = csv self.column = column self.column2 = column2 def setCsv(self, csv): self.csv = pd.read_csv(csv) def setColumn(self, column): self.column = column def setColumn2(self, column2): self.column2 = column2 def getCsv(self): return self.csvName def getColumn(self): return self.column def getColumn2(self): return self.column2 def sumCompare(self): column1sum = self.csv[self.column].sum() column2sum = self.csv[self.column2].sum() result="" if column1sum > column2sum: columnDifference = column1sum-column2sum result="Sum of all values in " + self.column + " is " + str(column1sum) +". Sum of all values in " + \ self.column2 + " is " + str(column2sum) + ". Sum of all values in " + self.column + \ " is greater than the sum of all values in " + self.column2 + ". " + self.column + \ " is greater than sum of " + self.column2 + " by " + str(columnDifference) elif column2sum > column1sum: columnDifference = column2sum-column1sum result="Sum of all values in " + self.column + " is " + str(column1sum) + ". Sum of all values in " +\ self.column2 + " is " + str(column2sum) + ". Sum of all values in " + self.column2 + \ " is greater than the sum of all values in " + self.column + ". " + self.column2 + \ "is greater than sum of " + self.column + " by " + str(columnDifference) elif column1sum == column2sum: result="Sum of all values in " + self.column + " is " + str(column1sum) +". Sum of all values in " + \ self.column2 + " is " + str(column2sum) + ". Sum of all values in " + self.column + \ " is equal to the sum of all values in " + self.column2 + "." return result def avgCompare(self): column1avg = self.csv[self.column].mean() column2avg = self.csv[self.column2].mean() if column1avg > column2avg: columnDifference = column1avg-column2avg return "Average of " + self.column + " is " + str(column1avg) + " and average of " + self.column2 + \ " is " + str(column2avg) + ". Average of " + self.column + " is greater than " + self.column2 + \ " by " + str(columnDifference) elif column2avg > column1avg: columnDifference = column2avg - column1avg return "Average of " + self.column + " is " + str(column1avg) + " and average of " + self.column2 + \ " is " + str(column2avg) + ". Average of " + self.column2 + " is greater than " + self.column + \ " by " + str(columnDifference) elif column2avg == column1avg: return "Average of " + self.column + " is " + str(column1avg) + " and average of " + self.column2 + \ " is " + str(column2avg) + ". Average of " + self.column2 + " is equal to " + self.column def totalCompare(self, filename): file = open((filename+".txt"),"w") file.write(self.sumCompare()) file.write("") file.write(self.avgCompare()) file.close() print("Exiting totalCompare") test = EnergyAnalysis("2016 Q1Q4 - Electrical.csv", "HS-Kitchen Emergency (kWh)", "HS Main (kWh)") test.totalCompare("test1") print("Done") The output is in a .txt file where it compares the two columns
0 Comments
Samar and I got back and started to work on the .CSV files that Mr. Navkal sent us and the one at the library.
Our Goal was to:
import pandas as pd # 2016 EnergyUsage2016 = pd.read_csv("2016 Q1Q4 - Electrical.csv") print("2016") sumOfEnergyUsage2016 = EnergyUsage2016.sum() print(sumOfEnergyUsage2016) print() print() HS2016kWh = EnergyUsage2016['HS Main (kWh)'].sum() + EnergyUsage2016['HS DHB Plugload (kWh)'].sum() + \ EnergyUsage2016['HS DL Lighting (kWh)'].sum() + EnergyUsage2016['HS-Kitchen Emergency (kWh)'].sum() + \ EnergyUsage2016['HS DG Gym (kWh)'].sum() + EnergyUsage2016['HS M1 Chillers (kWh)'].sum() + \ EnergyUsage2016['HS CC (kWh)'].sum() CollinsCenter2016 = EnergyUsage2016['HS CC (kWh)'].sum() PercentUsage2016 = CollinsCenter2016/HS2016kWh * 100 print("Energy used in 2016 by AHS was " + str(HS2016kWh) + " kWh.") print("Energy used in 2016 by the Collins center was " + str(CollinsCenter2016) + " kWh.") print("The Collins Center contributed " + str(PercentUsage2016) + "% of AHS's total energy consumption in 2016.") print() print() print() print() # 2017 EnergyUsage2017 = pd.read_csv("2017 Q1Q4 - Electrical Energy Daily.csv") print("2017") sumOfEnergyUsage2017 = EnergyUsage2017.sum() print(sumOfEnergyUsage2017) print() print() HS2017kWh = EnergyUsage2017['HS Main (kWh)'].sum() + EnergyUsage2017['HS DHB Plugload (kWh)'].sum() + \ EnergyUsage2017['HS DL Lighting (kWh)'].sum() + EnergyUsage2017['HS-Kitchen Emergency (kWh)'].sum() + \ EnergyUsage2017['HS DG Gym (kWh)'].sum() + EnergyUsage2017['HS PBA AHU1- 4 (KWh)'].sum() + \ EnergyUsage2017['HS M1 Chillers (kWh)'].sum() + EnergyUsage2017['HS CC (kWh)'].sum() + \ EnergyUsage2017['HS Gas (100 Cu Ft)'].sum() * 29 CollinsCenter2017 = EnergyUsage2017['HS CC (kWh)'].sum() PercentUsage2017 = CollinsCenter2017/HS2017kWh * 100 print("The amount of energy used in 2017 by AHS was " + str(HS2017kWh) + " kWh.") print("The amount of energy used in 2017 by the Collins center was " + str(CollinsCenter2017) + " kWh.") print("The Collins Center contributed " + str(float(PercentUsage2017)) + "% of AHS's total energy consumption in 2017.") This was the output /Users/ayushzenith/PycharmProjects/Energize1/venv/bin/python /Users/ayushzenith/PycharmProjects/Energize1/venv/playground.py 2016 HS Main (kWh) 1705498.00 HS DL Lighting (kWh) 425014.40 HS-Kitchen Emergency (kWh) 384582.40 HS DHB Plugload (kWh) 146111.61 HS DG Gym (kWh) 377604.80 HS M1 Chillers (kWh) 37243.27 HS CC (kWh) 309461.50 dtype: float64 Energy used in 2016 by AHS was 3385515.98 kWh. Energy used in 2016 by the Collins center was 309461.5 kWh. The Collins Center contributed 9.14074846576267% of AHS's total energy consumption in 2016. 2017 HS Main (kWh) 1573257.000 HS DHB Plugload (kWh) 142503.700 HS DL Lighting (kWh) 382167.700 HS-Kitchen Emergency (kWh) 387982.600 HS DG Gym (kWh) 343008.500 HS PBA AHU1- 4 (KWh) 10360.216 HS M1 Chillers (kWh) 36628.880 HS CC (kWh) 276071.900 HS Gas (100 Cu Ft) 7546.000 dtype: float64 The amount of energy used in 2017 by AHS was 3370814.496 kWh. The amount of energy used in 2017 by the Collins center was 276071.9 kWh. The Collins Center contributed 8.190065051862174% of AHS's total energy consumption in 2017. Process finished with exit code 0 During this meet we discussed about the water supply system for the Town of Andover. So it all starts at the source which is the Merrimack river. From the Merrimack river water is taken into the Fishbrook pump station from where the water is pumped to the Haggetts pond. Then low lift pumps that reside next to the pond pump the water up to the water plant. From the water plant the water is diverted in two ways one in which the west side pumps pump it to the wood hill tank and the other where the Bancroft pumps pump the water to the reservoir and soon the Prospect hill tank. Water is then distributed to residents from the Wood hill and prospect hill tanks.
We then learnt a few tricks in spredsheets and hoe to use spreadsheets to do simple math and so on.We also converted all of our water units to gallons. We then calculated how much water we use everyday, the cost of it, and the cost of water per person. This week we had a little more relaxed meet where we learnt about a few features in google maps like measuring the direct distance between two places using the markers. We then moved on to geosheets and in geosheets we learnt how to make our own maps that show different landmarks and how we can give these landmarks different icons and colors.
This meet we discussed about the expenses the town faces and we compared that to the expenses that we pay as residents of a town. So we approximated that the town pays $480 per million gallons of water to purify, store, and supply it to us. Then we calculated the amount of money that we pay to the town and we came out to $4264 per million gallons. The difference between what the town pays and what we pay them is huge. The difference is almost 10 times larger for us, but it is still cheaper then electricity or gas.
We also calculated the expenses the town would have if there was a leak and when there is a leak the water is not pumped to the user either. So when there is a leak the loss is only for the amount of water. We next calculated how much of a loss meter errors are for the town and surprisingly meter errors have a substantial loss, almost 10 times more expensive than leaks! Meter errors tend to be more expensive because the water is treated and pumped all the way to the user and the user doesn't pay for the water and neither the treatment. While leaks are not pumped up to the user and it is not used by the user. Today we talked about different measuring rates(i.e. 1 watt hr = 860 calories, 1000 calories = 1 food calorie, 2000 food calorie = 2324 watt hr). We soon saw this from different views like how we can survive on 50 cents per day if we could survive by eating electricity.
We also compared gas heating and electric heating and concluded that electricity is not good for heating as there is an 80% efficiency in a gas or coal boiler and only a 40% efficiency in electric turbines. We soon discussed our gas bills and discussed more measuring rates(i.e. 1 therm = $1.2, 1 Kw = $0.21, 1 Therm=29.3 KwH). We also discussed about how much water an average person from different countries use like in Africa an average person might use 75 liters a day while in France an average person might use 287 liters a day. By-
Ayush Zenith Samar Seth During our third meeting, we looked at the meters in the house. These include the water meter, gas meter, electricity meter. While experimenting with the water meter, we found that a small leak will not be registered by the meter, meaning that the town pays for that wasted water. However, you can almost always hear a leak through the pipes. If the water meter is moving as well, then you know it is a big leak. The faster it moves, the bigger the leak. For the electricity meter, we learned that there are two types of electrical meters, digital and analog, and it shows your electricity usage in kWh. The water and gas meters on the other hand, are measured in cubic feet. The gas meter is very complicated; there are 6 ways to turn the gas off in the house! We also learnt that on the road outside the house, there are yellow markings that show where the gas main is to your house. This means that if there is a fire, the fire department can turn off the gas supply to the house from outside so there are no explosions. There is also a similar marking for the water main, which is there in case of a flood. By-
Ayush Zenith Samar Seth For every 100 kWh of energy put into a generator, only 40 kWh can be used. This means that there is a 60% loss of energy in the form of heat. We also learnt a few conversion rates between sources of energy and kWh: 1 ton of coal = 8141 kWh, 100 mW = 100000 kWh = 12.28 tons of coal, 5000 mW = 614.18 tons of coal, and 1 gallon of gas = 35 kWh. Since we learnt that a generator produces 2000 mW of energy per hour, we found out use 5000 mW of energy to create 2000 mW of electricity per hour. Based on this data, we can calculate how much coal will be needed to power our houses per month and per year. We also learnt that one train carries approximately 15,000 tons of coal. This means that nearly one full train’s worth of coal is used every day by a single generator (24*614.18 = 14740.32). And if not coal, then the generator is using natural gas or nuclear energy. While we may have thought that a house would obviously use more energy than a car, we were completely wrong. Since 1 gallon of gas creates 35 kWh of energy, cars use about 525 kWh of energy per week. In comparison, the average house uses 600-700 kWh of energy in a month. This means that one car uses about 4 times as much energy as a house. We also learnt how much electricity is used by many products that we use in our everyday life.(i.e. Laptop, TV, and convection oven). The most astounding one was the Oven which used 533 Watts, then came the tv with 166 Watts, and last came the laptop which used 69 Watts. By-
Ayush Zenith Samar Seth In our first meeting we looked at the energy efficiency of different kinds of lightbulbs. The first thing we talked about were the different units used to measure the energy usage of an object. There are Watts, Volts, and Amps. In order to measure these we used a multimeter and we learned a few formulas relating to these units. These formulas were:VI=Wand IR=V. In these equations V means volts, I means amps, W means watts, and R means ohms. We tested halogen light bulbs, CFL light bulbs, and LED light bulbs. Of the three, LED was the most efficient. The halogen light bulb used 117.8 volts, the CFL light bulb used 59.4 volts, and the LED bulb used 9.8 volts. We also used both digital and dial calipers to measure the width of plug end of the light bulbs. We found that one side of the plug was 0.32 inches and the other side was 0.25 inches. We also found that the electricity only traveled through the smaller side of the plug. Another thing we looked at was the outlet itself. We found out that most modern outlets are tamper resistant so that babies won’t get electrocuted by sticking things in the outlet. We also looked at what the control panels for the electricity in the house look like and what the circuit breakers within them control. We talked about what the numbers and labels on the panels mean. In addition, we looked at how solar panels can create enough energy to make a house completely self-sufficient and return electricity back to the town. |
AuthorHi! My name is Ayush Zenith! I am currently a senior at Andover High School. I have been part of the Energize Andover Program since June, 2017 (8th grade). I have since been working on improving my knowledge in programming and working on writing better applications in order to save and conserve resources in buildings... Archives
November 2020
Categories |