# This is a sample Python script. # Press âR to execute it or replace it with your code. # Press Double â§ to search everywhere for classes, files, tool windows, actions, and settings. # See PyCharm help at https://www.jetbrains.com/help/pycharm/ import networkx as nx import pylab import numpy as np import pandas as pd import seaborn as sn import math from datetime import datetime import calendar import matplotlib.pyplot as plt df = pd.read_csv("./a6c2de4a.csv")#读åå ±äº«åè½¦æ°æ® #tiqu å ³é®å段 #ä¸è¾¹éè¦æ ¹æ®è®¢åèµ·ç¹åç»ç¹ç»çº¬åº¦ç¡®å®èµ·ç¹åç»ç¹çå¯ä¸ç¼ç ï¼è¿éæ¯ä½¿ç¨geopandaså°è®¢åODç¹è½¬ä¸ºäºç¹å¾å±ï¼ç¶åæåOç¹åDç¹ï¼ä»¥å计ç®ODä¹é´çè·ç¦»å为边çæéã import pandas as pd import geopandas as gpd import os from shapely.geometry import Point df = df[['start_location_x', 'start_location_y', 'end_location_x', 'end_location_y']] df['source'] = '(' + df['start_location_x'].map(str) + ',' + df['start_location_y'].map(str) + ')' df['target'] = '(' + df['end_location_x'].map(str) + ',' + df['end_location_y'].map(str) + ')' df['weight'] = ((df['start_location_x'] - df['end_location_x']).apply(lambda x: x ** 2) + (df['start_location_y'] - df['end_location_y']).apply(lambda x: x ** 2)).apply(lambda x: x**0.5) # df['label'] = df['source'] # df['lng'] = df['start_location_x'] # df['lat'] = df['start_location_y'] # df_node = df[['label', 'lng', 'lat']] df = df[['source', 'target', 'weight']] df = df.head(6000) # df_node = df_node.head(1000) df.to_csv('out.csv',index=False) # df_node.to_csv('out_node1.csv',index=False)