<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def calculate_mvgd_voltage_current_stats(nw):
 """ MV Voltage and Current Statistics for an arbitrary network Parameters nw: :any:`list` of NetworkDing0 The MV grid(s) to be studied Returns ------- pandas.DataFrame nodes_df : Dataframe containing voltage statistics for every node in the MVGD pandas.DataFrame lines_df : Dataframe containing voltage statistics for every edge in the MVGD """

    ##############################
    # close circuit breakers
    nw.control_circuit_breakers(mode='close')
    ##############################
    nodes_idx = 0
    nodes_dict = {}
    branches_idx = 0
    branches_dict = {}
    for district in nw.mv_grid_districts():
        # nodes voltage
        for node in district.mv_grid.graph_nodes_sorted():
            nodes_idx += 1
            if hasattr(node, 'voltage_res'):
                Vres0 = node.voltage_res[0]
                Vres1 = node.voltage_res[1]
            else:
                Vres0 = 'Not available'
                Vres1 = 'Not available'
            nodes_dict[nodes_idx] = {'MV_grid_id': district.mv_grid.id_db,
                                     'node id': node.__repr__(),
                                     'V_res_0': Vres0,
                                     'V_res_1': Vres1,
                                     'V nominal': district.mv_grid.v_level}
        # branches currents
        for branch in district.mv_grid.graph_edges():
            branches_idx += 1
            if hasattr(branch['branch'], 's_res'):
                s_res0 = branch['branch'].s_res[0]
                s_res1 = branch['branch'].s_res[1]
            else:
                s_res0 = 'Not available'
                s_res1 = 'Not available'

            branches_dict[branches_idx] = {
                'MV_grid_id': district.mv_grid.id_db,
                'branch id': branch['branch'].__repr__(),  # .id_db
                's_res_0': s_res0,
                's_res_1': s_res1,
                # 'length': branch['branch'].length / 1e3,
            }
    nodes_df = pd.DataFrame.from_dict(nodes_dict, orient='index')
    branches_df = pd.DataFrame.from_dict(branches_dict, orient='index')

    if not nodes_df.empty:
        nodes_df = nodes_df.set_index('node id')
        nodes_df = nodes_df.fillna(0)
        nodes_df = nodes_df[sorted(nodes_df.columns.tolist())]
        nodes_df.sort_index(inplace=True)

    if not branches_df.empty:
        branches_df = branches_df.set_index('branch id')
        branches_df = branches_df.fillna(0)
        branches_df = branches_df[sorted(branches_df.columns.tolist())]
        branches_df.sort_index(inplace=True)

    return (nodes_df, branches_df)