This is a rather specific follow up to this question on creating pandas dataframes when entries have different lengths.
I have a dataset where I have:
- general environmental variables that apply to the whole problem (e.g. avg precipitation)
- values at, say, specific depth (e.g. average amount of water at any depth after rainfall)
so my data looks like
d = dict{'depth': [1,2,3], 'var1',[.01,.009,.002],'globalvar',[2.5]}
df = pd.DataFrame(dict([ (k,pd.Series(v)) for k,v in d.items() ]))
>>
depth globalvar var1
0 1 2.5 0.010
1 2 NaN 0.009
2 3 NaN 0.002
Is there a way to call globalvar, e.g. df.globalvar
without calling df.globalvar[1]
? Is there a more pythonic way to do this?