I have the following data-set:
oxford, 20180101, tempmax, 140
oxford, 20180101, tempmin, 40
oxford, 20180102, tempmax, 160
oxford, 20180102, tempmin, 20
oxford, 20180103, tempmax, 90
oxford, 20180103, tempmin, 10
oxford, 20180104, tempmax, 200
oxford, 20180104, tempmin, 120
How can I read this file in, combine by location and date, and work out the temp difference in python?
example output:
oxford, 20180101, tdiff, 40
oxford, 20180102, tdiff, 160
oxford, 20180103, tdiff, 80
oxford, 20180104, tdiff, 80
What sort of manipulation in python could be used for this?
Try this
import pandas as pd
df = pd.DataFrame({"A":["oxford","oxford","oxford","oxford","oxford","oxford","oxford","oxford"],
"B":["20180101","20180101","20180102","20180102","20180103","20180103","20180104","20180104"],
"C":["tempmax","tempmin","tempmax","tempmin","tempmax","tempmin","tempmax","tempmin"],
"D":[140,40,160,20,90,10,200,120]})
df["B"] = pd.to_datetime(df["B"])
dfnew = df.sort_values(["B"]).groupby(['A', 'B'])["D"].apply(lambda x: (max(list(x))-min(list(x)))).reset_index()
dfnew["diff"] = "tdiff"
//output
A B D diff
0 oxford 2018-01-01 100 tdiff
1 oxford 2018-01-02 140 tdiff
2 oxford 2018-01-03 80 tdiff
3 oxford 2018-01-04 80 tdiff
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
I wrote code that prints an empty 20x20 tableThe main goal is to eventually make a program that creates a crossword
I am trying to make a small tetris game for learning python with kivyI am trying to create a custom widget with size 20,20
An annuity is a series of payments made at fixed intervals of timeIf you buy an annuity from a bank, you will pay a principal sum upfront, and then receive monthly or yearly payouts deducted from the principal
I am trying to understand how to print off a binary numbers digits individuallyFor example, if the binary number is 1011, I want to print to the console: