0
是否可以使用pandas.DataFrame
複製此csv的結構?multiheader pandas dataframe
所有數據被從一個HDF5
文件拉出,然後解析出的屬性到pd.DataFrame
我擔心是該meta header
和meta data
(線1和2在CSV )不符合attribute header
和attribute data
的長度或形狀。
這裏是我叫pd.DataFrame
:
# Meta Pandas DataFrame
meta_df = pd.DataFrame(index=range(0, 8760, 24), columns=['source', 'location_id', 'state', 'country', 'latitude',
'longitude', 'time_zone', 'elevation', 'clearsky_dhi',
'clearsky_dni', 'clearsky_ghi', 'dewpoint_unit',
'temperature_unit'])
# Meta Header & Data
meta_df['source'] = source
meta_df['location_id'] = location_id
meta_df['state'] = state
meta_df['country'] = country
meta_df['latitude'] = latitude
meta_df['longitude'] = longitude
meta_df['time_zone'] = local_time
meta_df['elevation'] = elevation
meta_df['clearsky_dhi'] = clearsky_dhi
meta_df['clearsky_dni'] = clearsky_dni
meta_df['clearsky_ghi'] = clearsky_ghi
meta_df['dewpoint_unit'] = dewpoint_unit
meta_df['temperature_unit'] = temperature_unit
# Attribute Pandas DataFrame
att_df = pd.DataFrame(index=range(0, 8760, 24), columns=['dhi', 'dni', 'ghi', 'source', 'dew_point', 'temperature'])
# Attribute Header & Data
att_df['year'] = year
att_df['month'] = month
att_df['day'] = day
att_df['hour'] = hour
att_df['minute'] = minute
att_df['dhi'] = dhi
att_df['dni'] = dni
att_df['ghi'] = ghi
att_df['dew_point'] = dew_point
att_df['temperature'] = temperature
# Make one DataFrame with multiple headers?
# Do something, then export to csv.
df.to_csv(ndir_root + ndir + '/' + fname + '.csv', index=False)
是它最好創建兩個單獨的dataframes,然後將它們堆疊垂直創建第三個數據幀並導出最終爲CSV?
bueller?