<commit_before>__author__ = 'max'

import gpxpy
import pandas as pd


def parse_gpx(gpx_file_name):
    return gpxpy.parse(gpx_file_name)


def data_frame_for_track_segment(segment):
    seg_dict = {}

    for point in segment.points:
        seg_dict[point.time] = [point.latitude, point.longitude,
                                point.elevation, point.speed]
    seg_frame = pd.DataFrame(data=seg_dict)
    # Switch columns and rows s.t. timestamps are rows and gps data columns.
    seg_frame = seg_frame.T
    seg_frame.columns = ['latitude', 'longitude', 'altitude', 'speed']
    return seg_frame


def track_segment_mapping(track):
    segments = [data_frame_for_track_segment(segment)
                for segment in track.segments]
    return segments


def pandas_data_frame_for_gpx(gpx):
    tracks_frames = [track_segment_mapping(track) for track in gpx.tracks]
    # Create a hierarchical DataFrame by unstacking.
    tracks_frame = pd.DataFrame(tracks_frames)
    return tracks_frame.unstack()<commit_msg>Replaced list generators by an iterative generators<commit_after>__author__ = 'max'

import gpxpy
import pandas as pd


def parse_gpx(gpx_file_name):
    return gpxpy.parse(gpx_file_name)


def data_frame_for_track_segment(segment):
    seg_dict = {}

    for point in segment.points:
        seg_dict[point.time] = [point.latitude, point.longitude,
                                point.elevation, point.speed]
    seg_frame = pd.DataFrame(data=seg_dict)
    # Switch columns and rows s.t. timestamps are rows and gps data columns.
    seg_frame = seg_frame.T
    seg_frame.columns = ['latitude', 'longitude', 'altitude', 'speed']
    return seg_frame


def track_segment_mapping(track):
    segments = (data_frame_for_track_segment(segment)
                for segment in track.segments)
    return segments


def pandas_data_frame_for_gpx(gpx):
    tracks_frames = (track_segment_mapping(track) for track in gpx.tracks)
    # Create a hierarchical DataFrame by unstacking.
    tracks_frame = pd.DataFrame(tracks_frames)
    return tracks_frame.unstack()
{'fraction_non_alphanumeric': 0.08293153326904533, 'fraction_numerical': 0.0, 'mean_word_length': 3.520697167755991, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2845092', 'n_tokens_mistral': 682, 'n_tokens_neox': 651, 'n_words': 155}