Commit 6d87d9e1 by arun.uday

all

parent 70f50136
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (task5)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (task5 - Copy)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
......@@ -2,7 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/task5.iml" filepath="$PROJECT_DIR$/.idea/task5.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/task5pandas_op.iml" filepath="$PROJECT_DIR$/.idea/task5pandas_op.iml" />
</modules>
</component>
</project>
\ No newline at end of file
......@@ -4,7 +4,7 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="jdk" jdkName="Python 3.9 (task5 - Copy)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
......@@ -9,11 +9,11 @@ def time_change(file):
file_copy['Timestamp'] = file_copy['Timestamp'].dt.strftime(date_format)
# for storing the pivoted frame to dictionary
dict_cols = {}
dict_cols = []
for i in range(0, len(file_copy.columns)):
key_dict = "label" + str(i)
val_dict = file_copy.columns[i]
dict_cols.update({key_dict: val_dict})
key_dict = file_copy.columns[i]
val_dict = file_copy.columns[i].lower()
dict_cols.append({key_dict: val_dict})
# storing the header and body to json
head_cols = {"header": dict_cols}
......
......@@ -5,14 +5,15 @@ def melt_frame(file):
file_copy = file
# creating the melted dataframe melted_file
melted_file = file_copy.melt(id_vars=['Timestamp'], value_vars=['kWh'])
melted_file = file_copy.melt(id_vars=['Timestamp'])
print(melted_file)
# for storing the melted frame to dictionary
dict_cols = {}
dict_cols = []
for i in range(0, len(melted_file.columns)):
key_dict = "label" + str(i)
val_dict = melted_file.columns[i]
dict_cols.update({key_dict: val_dict})
dict_cols.append({key_dict: val_dict})
# storing the header and body to json
head_cols = {"header": dict_cols}
......
......@@ -11,13 +11,14 @@ def merge_frame(file):
# creating the merged dataframe merged_file
merged_file = pd.merge(file_frame1, file_frame2, on='Timestamp')
print(merged_file)
# for storing the merged frame to dictionary
dict_cols = {}
dict_cols = []
for i in range(0, len(merged_file.columns)):
key_dict = "label" + str(i)
val_dict = merged_file.columns[i]
dict_cols.update({key_dict: val_dict})
dict_cols.append({key_dict: val_dict})
# storing the header and body to json
head_cols = {"header": dict_cols}
......
......@@ -3,18 +3,16 @@
def pivot_frame(file):
file_copy = file
# pivoting the data
pivoted_d = file_copy.pivot_table(index='Timestamp', columns=[],
values=file_copy)
print(pivoted_d)
# for storing the pivoted frame to dictionary
dict_cols = {}
dict_cols = []
for i in range(0, len(pivoted_d.columns)):
key_dict = "label"+str(i)
val_dict = pivoted_d.columns[i]
dict_cols.update({key_dict: val_dict})
dict_cols.append({key_dict: val_dict})
# storing the header and body to json
head_cols = {"header": dict_cols}
body_vals = {"body": pivoted_d.to_dict(orient="records")}
......
{
"header": {
"label0": "Timestamp",
"label1": "kW",
"label2": "kVA"
},
"header": [
{
"label0": "Timestamp"
},
{
"label1": "kW"
},
{
"label2": "kVA"
}
],
"body": [
{
"Timestamp": "01-12-19 00-00-21",
......
{
"header": {
"label0": "current",
"label1": "kVA",
"label2": "kVAh",
"label3": "kW",
"label4": "kWh"
},
"header": [
{
"label0": "current"
},
{
"label1": "kVA"
},
{
"label2": "kVAh"
},
{
"label3": "kW"
},
{
"label4": "kWh"
}
],
"body": [
{
"current": 281.58292388916016,
......
{
"header": {
"label0": "Timestamp",
"label1": "kWh",
"label2": "kVAh",
"label3": "kW",
"label4": "kVA",
"label5": "current"
},
"header": [
{
"Timestamp": "timestamp"
},
{
"kWh": "kwh"
},
{
"kVAh": "kvah"
},
{
"kW": "kw"
},
{
"kVA": "kva"
},
{
"current": "current"
}
],
"body": [
{
"Timestamp": "01-12-19 00-00-21",
......
......@@ -18,14 +18,14 @@ def access_op():
print("Pivoting the dataframe")
dict_data_pivoted, pivot_change = json_pandas.pivot_data(file_concat)
json_pandas.create_json(path_pivot, pivot_change)
json_pandas.create_json(path_pivot, dict_data_pivoted)
print("Melting the dataframe")
melt_change = json_pandas.melt_data(dict_data_pivoted)
melt_change = json_pandas.melt_data(file_concat)
json_pandas.create_json(path_melt, melt_change)
print("Merging the dataframe")
merge_change = json_pandas.merge_data(dict_data_pivoted)
merge_change = json_pandas.merge_data(file_concat)
json_pandas.create_json(path_merge, merge_change)
except Exception as e:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment