Learn
In [1]:
Copied!
cars=["audi", "bmw", "subaru", "toyota"]
for car in cars:
if car != "bmw":
print(car.upper())
else:
print(car.title())
print("done")
cars=["audi", "bmw", "subaru", "toyota"]
for car in cars:
if car != "bmw":
print(car.upper())
else:
print(car.title())
print("done")
AUDI Bmw SUBARU TOYOTA done
In [2]:
Copied!
counter = 0
while counter < 10:
counter += 1
if counter % 2 == 0:
continue
print(counter)
counter = 0
while counter < 10:
counter += 1
if counter % 2 == 0:
continue
print(counter)
1 3 5 7 9
In [3]:
Copied!
def describe_pet(animal_type, pet_name):
print(f"I have a {animal_type}")
print(f"My {animal_type}'s name is {pet_name}")
describe_pet("dog", pet_name="willie")
#位置参数必须在关键字参数之前
def describe_pet(animal_type, pet_name):
print(f"I have a {animal_type}")
print(f"My {animal_type}'s name is {pet_name}")
describe_pet("dog", pet_name="willie")
#位置参数必须在关键字参数之前
I have a dog My dog's name is willie
In [4]:
Copied!
# 打印ASCII码前60个字符及其序号
for i in range(60):
print(f"{i}: {chr(i)}")
# 打印ASCII码前60个字符及其序号
for i in range(60):
print(f"{i}: {chr(i)}")
0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: ! 34: " 35: # 36: $ 37: % 38: & 39: ' 40: ( 41: ) 42: * 43: + 44: , 45: - 46: . 47: / 48: 0 49: 1 50: 2 51: 3 52: 4 53: 5 54: 6 55: 7 56: 8 57: 9 58: : 59: ;
In [5]:
Copied!
def describe_student(name,major='Gis'):
print(f"{name} is major in {major}")
describe_student('Tom',major='Math')
describe_student('Tom')
describe_student('Tom','English')
#为什么要使用默认值?因为这样可以简化函数调用,同时也可以让函数更具有通用性,还能换用不同的默认值
def describe_student(name,major='Gis'):
print(f"{name} is major in {major}")
describe_student('Tom',major='Math')
describe_student('Tom')
describe_student('Tom','English')
#为什么要使用默认值?因为这样可以简化函数调用,同时也可以让函数更具有通用性,还能换用不同的默认值
Tom is major in Math Tom is major in Gis Tom is major in English
In [6]:
Copied!
def sum_values(values):
final= []
for value in values:
try:
final.append(float(value))
except:
pass
total = sum(final)
return total
sum_values([1,2,3,4,5,'fd'])
def sum_values(values):
final= []
for value in values:
try:
final.append(float(value))
except:
pass
total = sum(final)
return total
sum_values([1,2,3,4,5,'fd'])
Out[6]:
15.0
In [7]:
Copied!
def sum_values(values):
final= []
if not isinstance(values, list):
print("The input is not a list")
return None
if isinstance(values, (int, float)):
values = [values]
for value in values:
try:
final.append(float(value))
except:
pass
total = sum(final)
return total
sum_values([1,2,3,4,5,'fd'])
#sum_values(hasattr)
def sum_values(values):
final= []
if not isinstance(values, list):
print("The input is not a list")
return None
if isinstance(values, (int, float)):
values = [values]
for value in values:
try:
final.append(float(value))
except:
pass
total = sum(final)
return total
sum_values([1,2,3,4,5,'fd'])
#sum_values(hasattr)
Out[7]:
15.0
In [8]:
Copied!
class Car:
"""A simple attempt to represent a car."""
def __init__(self, make, model, year):
"""Initialize attributes to describe a car."""
self.make = make
self.model = model
self.year = year
self.odometer_reading = 0 #设置默认值
def get_descriptive_name(self):
"""Return a neatly formatted descriptive name."""
# long_name = f"{self.year} {self.make} {self.model}"
# return long_name.title() #这里return 后面就用print打印
print(f"{self.year} {self.make} {self.model}".title())
#这里print了,后面就直接调用函数就行
def read_odometer(self):
"""Print a statement showing the car's mileage."""
print(f"This car has {self.odometer_reading} miles on it.")
my_new_car = Car("audi", "a4", 2019)
# print(my_new_car.get_descriptive_name())
my_new_car.get_descriptive_name()
my_new_car.read_odometer()
class Car:
"""A simple attempt to represent a car."""
def __init__(self, make, model, year):
"""Initialize attributes to describe a car."""
self.make = make
self.model = model
self.year = year
self.odometer_reading = 0 #设置默认值
def get_descriptive_name(self):
"""Return a neatly formatted descriptive name."""
# long_name = f"{self.year} {self.make} {self.model}"
# return long_name.title() #这里return 后面就用print打印
print(f"{self.year} {self.make} {self.model}".title())
#这里print了,后面就直接调用函数就行
def read_odometer(self):
"""Print a statement showing the car's mileage."""
print(f"This car has {self.odometer_reading} miles on it.")
my_new_car = Car("audi", "a4", 2019)
# print(my_new_car.get_descriptive_name())
my_new_car.get_descriptive_name()
my_new_car.read_odometer()
2019 Audi A4 This car has 0 miles on it.
In [9]:
Copied!
class telsa(Car):
def __init__(self, make, model, year):
super().__init__(make, model, year)
#super()是一个特殊函数,帮助Python将父类和子类关联起来
self.battery_size = 75
def describe_battery(self):
print(f"This car has a {self.battery_size}-kWh battery.")
my_telsa = telsa('telsa','model s',2020)
my_telsa.get_descriptive_name()
my_telsa.describe_battery()
my_telsa.odometer_reading = 23
my_telsa.read_odometer()
class telsa(Car):
def __init__(self, make, model, year):
super().__init__(make, model, year)
#super()是一个特殊函数,帮助Python将父类和子类关联起来
self.battery_size = 75
def describe_battery(self):
print(f"This car has a {self.battery_size}-kWh battery.")
my_telsa = telsa('telsa','model s',2020)
my_telsa.get_descriptive_name()
my_telsa.describe_battery()
my_telsa.odometer_reading = 23
my_telsa.read_odometer()
2020 Telsa Model S This car has a 75-kWh battery. This car has 23 miles on it.
In [10]:
Copied!
%pip install leafmap
import leafmap
m = leafmap.Map()
#m.add_basemap("HYBRID")
class MAP(leafmap.Map):
def __init__(self):
super().__init__()
self.add_basemap("HYBRID")
self.clear_controls()
#clear_controls()是一个方法,用于清除地图上的所有控件
m1 = MAP()
m1
%pip install leafmap
import leafmap
m = leafmap.Map()
#m.add_basemap("HYBRID")
class MAP(leafmap.Map):
def __init__(self):
super().__init__()
self.add_basemap("HYBRID")
self.clear_controls()
#clear_controls()是一个方法,用于清除地图上的所有控件
m1 = MAP()
m1
Collecting leafmap Downloading leafmap-0.35.9-py2.py3-none-any.whl.metadata (17 kB)
Collecting bqplot (from leafmap) Downloading bqplot-0.12.43-py2.py3-none-any.whl.metadata (6.4 kB) Collecting colour (from leafmap) Downloading colour-0.1.5-py2.py3-none-any.whl.metadata (18 kB)
Collecting duckdb (from leafmap) Downloading duckdb-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (762 bytes)
Collecting folium (from leafmap) Downloading folium-0.17.0-py2.py3-none-any.whl.metadata (3.8 kB) Collecting gdown (from leafmap) Downloading gdown-5.2.0-py3-none-any.whl.metadata (5.8 kB)
Collecting geojson (from leafmap) Downloading geojson-3.1.0-py3-none-any.whl.metadata (16 kB)
Collecting ipyevents (from leafmap) Downloading ipyevents-2.0.2-py3-none-any.whl.metadata (2.9 kB)
Collecting ipyfilechooser (from leafmap) Downloading ipyfilechooser-0.6.0-py3-none-any.whl.metadata (6.4 kB) Requirement already satisfied: ipyleaflet in /home/runner/.local/lib/python3.11/site-packages (from leafmap) (0.19.1) Collecting ipyvuetify (from leafmap) Downloading ipyvuetify-1.9.4-py2.py3-none-any.whl.metadata (7.4 kB)
Requirement already satisfied: ipywidgets in /home/runner/.local/lib/python3.11/site-packages (from leafmap) (8.1.3)
Collecting matplotlib (from leafmap) Downloading matplotlib-3.9.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (11 kB)
Requirement already satisfied: numpy<3.0.0 in /home/runner/.local/lib/python3.11/site-packages (from leafmap) (2.0.0)
Collecting pandas (from leafmap) Downloading pandas-2.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (19 kB)
Collecting plotly (from leafmap) Downloading plotly-5.22.0-py3-none-any.whl.metadata (7.1 kB)
Collecting pyshp (from leafmap)
Downloading pyshp-2.3.1-py2.py3-none-any.whl.metadata (55 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/56.0 kB ? eta -:--:--
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 56.0/56.0 kB 19.2 MB/s eta 0:00:00
Collecting pystac-client (from leafmap) Downloading pystac_client-0.8.2-py3-none-any.whl.metadata (5.2 kB) Collecting python-box (from leafmap)
Downloading python_box-7.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (7.8 kB) Collecting scooby (from leafmap) Downloading scooby-0.10.0-py3-none-any.whl.metadata (15 kB)
Collecting whiteboxgui (from leafmap) Downloading whiteboxgui-2.3.0-py2.py3-none-any.whl.metadata (5.7 kB) Requirement already satisfied: xyzservices in /home/runner/.local/lib/python3.11/site-packages (from leafmap) (2024.6.0) Requirement already satisfied: traitlets>=4.3.0 in /home/runner/.local/lib/python3.11/site-packages (from bqplot->leafmap) (5.14.3) Requirement already satisfied: traittypes>=0.0.6 in /home/runner/.local/lib/python3.11/site-packages (from bqplot->leafmap) (0.2.1) Requirement already satisfied: comm>=0.1.3 in /home/runner/.local/lib/python3.11/site-packages (from ipywidgets->leafmap) (0.2.2) Requirement already satisfied: ipython>=6.1.0 in /home/runner/.local/lib/python3.11/site-packages (from ipywidgets->leafmap) (8.26.0) Requirement already satisfied: widgetsnbextension~=4.0.11 in /home/runner/.local/lib/python3.11/site-packages (from ipywidgets->leafmap) (4.0.11)
Requirement already satisfied: jupyterlab-widgets~=3.0.11 in /home/runner/.local/lib/python3.11/site-packages (from ipywidgets->leafmap) (3.0.11) Requirement already satisfied: python-dateutil>=2.8.2 in /home/runner/.local/lib/python3.11/site-packages (from pandas->leafmap) (2.9.0.post0) Requirement already satisfied: pytz>=2020.1 in /home/runner/.local/lib/python3.11/site-packages (from pandas->leafmap) (2024.1) Collecting tzdata>=2022.7 (from pandas->leafmap) Downloading tzdata-2024.1-py2.py3-none-any.whl.metadata (1.4 kB) Requirement already satisfied: branca>=0.6.0 in /home/runner/.local/lib/python3.11/site-packages (from folium->leafmap) (0.7.2) Requirement already satisfied: jinja2>=2.9 in /home/runner/.local/lib/python3.11/site-packages (from folium->leafmap) (3.1.4) Requirement already satisfied: requests in /home/runner/.local/lib/python3.11/site-packages (from folium->leafmap) (2.32.3) Requirement already satisfied: beautifulsoup4 in /home/runner/.local/lib/python3.11/site-packages (from gdown->leafmap) (4.12.3)
Collecting filelock (from gdown->leafmap) Downloading filelock-3.15.4-py3-none-any.whl.metadata (2.9 kB)
Collecting tqdm (from gdown->leafmap)
Downloading tqdm-4.66.4-py3-none-any.whl.metadata (57 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/57.6 kB ? eta -:--:--
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.6/57.6 kB 19.3 MB/s eta 0:00:00
Requirement already satisfied: jupyter-leaflet<0.20,>=0.19 in /home/runner/.local/lib/python3.11/site-packages (from ipyleaflet->leafmap) (0.19.1)
Collecting ipyvue<2,>=1.7 (from ipyvuetify->leafmap) Downloading ipyvue-1.11.1-py2.py3-none-any.whl.metadata (1.1 kB)
Collecting contourpy>=1.0.1 (from matplotlib->leafmap) Downloading contourpy-1.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (5.8 kB) Collecting cycler>=0.10 (from matplotlib->leafmap) Downloading cycler-0.12.1-py3-none-any.whl.metadata (3.8 kB)
Requirement already satisfied: fonttools>=4.22.0 in /home/runner/.local/lib/python3.11/site-packages (from matplotlib->leafmap) (4.53.1) Collecting kiwisolver>=1.3.1 (from matplotlib->leafmap)
Downloading kiwisolver-1.4.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.4 kB) Requirement already satisfied: packaging>=20.0 in /home/runner/.local/lib/python3.11/site-packages (from matplotlib->leafmap) (24.1) Requirement already satisfied: pillow>=8 in /home/runner/.local/lib/python3.11/site-packages (from matplotlib->leafmap) (10.4.0) Collecting pyparsing>=2.3.1 (from matplotlib->leafmap) Downloading pyparsing-3.1.2-py3-none-any.whl.metadata (5.1 kB)
Collecting tenacity>=6.2.0 (from plotly->leafmap) Downloading tenacity-8.5.0-py3-none-any.whl.metadata (1.2 kB) Collecting pystac>=1.10.0 (from pystac[validation]>=1.10.0->pystac-client->leafmap)
Downloading pystac-1.10.1-py3-none-any.whl.metadata (6.4 kB)
Collecting ipytree (from whiteboxgui->leafmap) Downloading ipytree-0.2.2-py2.py3-none-any.whl.metadata (849 bytes)
Collecting whitebox (from whiteboxgui->leafmap) Downloading whitebox-2.3.4-py2.py3-none-any.whl.metadata (10 kB) Requirement already satisfied: decorator in /home/runner/.local/lib/python3.11/site-packages (from ipython>=6.1.0->ipywidgets->leafmap) (5.1.1)
Requirement already satisfied: jedi>=0.16 in /home/runner/.local/lib/python3.11/site-packages (from ipython>=6.1.0->ipywidgets->leafmap) (0.19.1) Requirement already satisfied: matplotlib-inline in /home/runner/.local/lib/python3.11/site-packages (from ipython>=6.1.0->ipywidgets->leafmap) (0.1.7) Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in /home/runner/.local/lib/python3.11/site-packages (from ipython>=6.1.0->ipywidgets->leafmap) (3.0.47) Requirement already satisfied: pygments>=2.4.0 in /home/runner/.local/lib/python3.11/site-packages (from ipython>=6.1.0->ipywidgets->leafmap) (2.18.0) Requirement already satisfied: stack-data in /home/runner/.local/lib/python3.11/site-packages (from ipython>=6.1.0->ipywidgets->leafmap) (0.6.3) Requirement already satisfied: typing-extensions>=4.6 in /home/runner/.local/lib/python3.11/site-packages (from ipython>=6.1.0->ipywidgets->leafmap) (4.12.2) Requirement already satisfied: pexpect>4.3 in /home/runner/.local/lib/python3.11/site-packages (from ipython>=6.1.0->ipywidgets->leafmap) (4.9.0) Requirement already satisfied: MarkupSafe>=2.0 in /home/runner/.local/lib/python3.11/site-packages (from jinja2>=2.9->folium->leafmap) (2.1.5) Requirement already satisfied: jsonschema~=4.18 in /home/runner/.local/lib/python3.11/site-packages (from pystac[validation]>=1.10.0->pystac-client->leafmap) (4.23.0) Requirement already satisfied: six>=1.5 in /home/runner/.local/lib/python3.11/site-packages (from python-dateutil>=2.8.2->pandas->leafmap) (1.16.0) Requirement already satisfied: charset-normalizer<4,>=2 in /home/runner/.local/lib/python3.11/site-packages (from requests->folium->leafmap) (3.3.2) Requirement already satisfied: idna<4,>=2.5 in /home/runner/.local/lib/python3.11/site-packages (from requests->folium->leafmap) (3.7) Requirement already satisfied: urllib3<3,>=1.21.1 in /home/runner/.local/lib/python3.11/site-packages (from requests->folium->leafmap) (2.2.2) Requirement already satisfied: certifi>=2017.4.17 in /home/runner/.local/lib/python3.11/site-packages (from requests->folium->leafmap) (2024.7.4) Requirement already satisfied: soupsieve>1.2 in /home/runner/.local/lib/python3.11/site-packages (from beautifulsoup4->gdown->leafmap) (2.5)
Collecting PySocks!=1.5.7,>=1.5.6 (from requests[socks]->gdown->leafmap) Downloading PySocks-1.7.1-py3-none-any.whl.metadata (13 kB) Requirement already satisfied: Click>=6.0 in /home/runner/.local/lib/python3.11/site-packages (from whitebox->whiteboxgui->leafmap) (8.1.7) Requirement already satisfied: parso<0.9.0,>=0.8.3 in /home/runner/.local/lib/python3.11/site-packages (from jedi>=0.16->ipython>=6.1.0->ipywidgets->leafmap) (0.8.4) Requirement already satisfied: attrs>=22.2.0 in /home/runner/.local/lib/python3.11/site-packages (from jsonschema~=4.18->pystac[validation]>=1.10.0->pystac-client->leafmap) (23.2.0) Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /home/runner/.local/lib/python3.11/site-packages (from jsonschema~=4.18->pystac[validation]>=1.10.0->pystac-client->leafmap) (2023.12.1) Requirement already satisfied: referencing>=0.28.4 in /home/runner/.local/lib/python3.11/site-packages (from jsonschema~=4.18->pystac[validation]>=1.10.0->pystac-client->leafmap) (0.35.1) Requirement already satisfied: rpds-py>=0.7.1 in /home/runner/.local/lib/python3.11/site-packages (from jsonschema~=4.18->pystac[validation]>=1.10.0->pystac-client->leafmap) (0.19.0) Requirement already satisfied: ptyprocess>=0.5 in /home/runner/.local/lib/python3.11/site-packages (from pexpect>4.3->ipython>=6.1.0->ipywidgets->leafmap) (0.7.0) Requirement already satisfied: wcwidth in /home/runner/.local/lib/python3.11/site-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython>=6.1.0->ipywidgets->leafmap) (0.2.13)
Requirement already satisfied: executing>=1.2.0 in /home/runner/.local/lib/python3.11/site-packages (from stack-data->ipython>=6.1.0->ipywidgets->leafmap) (2.0.1) Requirement already satisfied: asttokens>=2.1.0 in /home/runner/.local/lib/python3.11/site-packages (from stack-data->ipython>=6.1.0->ipywidgets->leafmap) (2.4.1) Requirement already satisfied: pure-eval in /home/runner/.local/lib/python3.11/site-packages (from stack-data->ipython>=6.1.0->ipywidgets->leafmap) (0.2.2) Downloading leafmap-0.35.9-py2.py3-none-any.whl (1.9 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/1.9 MB ? eta -:--:--
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.9/1.9 MB 109.5 MB/s eta 0:00:00 Downloading bqplot-0.12.43-py2.py3-none-any.whl (1.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/1.2 MB ? eta -:--:-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 101.0 MB/s eta 0:00:00 Downloading pandas-2.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.0 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/13.0 MB ? eta -:--:--
━━━━━━━━━━━━━━━╸━━━━━━━━━━━━━━━━━━━━━━━━ 5.1/13.0 MB 152.0 MB/s eta 0:00:01
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸━━━━━━ 10.9/13.0 MB 160.7 MB/s eta 0:00:01 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸ 13.0/13.0 MB 167.9 MB/s eta 0:00:01 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.0/13.0 MB 111.3 MB/s eta 0:00:00 Downloading colour-0.1.5-py2.py3-none-any.whl (23 kB)
Downloading duckdb-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.5 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/18.5 MB ? eta -:--:-- ━━━━━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━ 6.7/18.5 MB 201.4 MB/s eta 0:00:01
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╺━━━━━━━━━━ 13.5/18.5 MB 198.2 MB/s eta 0:00:01
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸ 18.5/18.5 MB 200.2 MB/s eta 0:00:01 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 18.5/18.5 MB 107.9 MB/s eta 0:00:00 Downloading folium-0.17.0-py2.py3-none-any.whl (108 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/108.4 kB ? eta -:--:--
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 108.4/108.4 kB 32.9 MB/s eta 0:00:00 Downloading gdown-5.2.0-py3-none-any.whl (18 kB) Downloading geojson-3.1.0-py3-none-any.whl (15 kB) Downloading ipyevents-2.0.2-py3-none-any.whl (101 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/101.8 kB ? eta -:--:-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 101.8/101.8 kB 18.1 MB/s eta 0:00:00 Downloading ipyfilechooser-0.6.0-py3-none-any.whl (11 kB) Downloading ipyvuetify-1.9.4-py2.py3-none-any.whl (6.1 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/6.1 MB ? eta -:--:--
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸━━ 5.7/6.1 MB 176.3 MB/s eta 0:00:01 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.1/6.1 MB 115.8 MB/s eta 0:00:00 Downloading matplotlib-3.9.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/8.3 MB ? eta -:--:--
━━━━━━━━━━━━━━━━━━━━━━━━━━━━╺━━━━━━━━━━━ 5.9/8.3 MB 176.6 MB/s eta 0:00:01
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.3/8.3 MB 122.6 MB/s eta 0:00:00 Downloading plotly-5.22.0-py3-none-any.whl (16.4 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/16.4 MB ? eta -:--:-- ━━━━━━━━━━━━━╸━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.6/16.4 MB 169.4 MB/s eta 0:00:01
━━━━━━━━━━━━━━━━━━━━━━━━━━━╺━━━━━━━━━━━━ 11.1/16.4 MB 163.0 MB/s eta 0:00:01
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸ 16.4/16.4 MB 176.6 MB/s eta 0:00:01
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 16.4/16.4 MB 104.5 MB/s eta 0:00:00 Downloading pyshp-2.3.1-py2.py3-none-any.whl (46 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/46.5 kB ? eta -:--:-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 46.5/46.5 kB 15.2 MB/s eta 0:00:00 Downloading pystac_client-0.8.2-py3-none-any.whl (33 kB) Downloading python_box-7.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/4.3 MB ? eta -:--:--
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸ 4.3/4.3 MB 189.1 MB/s eta 0:00:01 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.3/4.3 MB 99.3 MB/s eta 0:00:00 Downloading scooby-0.10.0-py3-none-any.whl (18 kB) Downloading whiteboxgui-2.3.0-py2.py3-none-any.whl (108 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/108.6 kB ? eta -:--:-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 108.6/108.6 kB 33.9 MB/s eta 0:00:00 Downloading contourpy-1.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (306 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/306.0 kB ? eta -:--:-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 306.0/306.0 kB 74.0 MB/s eta 0:00:00 Downloading cycler-0.12.1-py3-none-any.whl (8.3 kB) Downloading ipyvue-1.11.1-py2.py3-none-any.whl (2.7 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/2.7 MB ? eta -:--:--
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.7/2.7 MB 121.7 MB/s eta 0:00:00 Downloading kiwisolver-1.4.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/1.4 MB ? eta -:--:-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.4/1.4 MB 115.4 MB/s eta 0:00:00 Downloading pyparsing-3.1.2-py3-none-any.whl (103 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/103.2 kB ? eta -:--:-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 103.2/103.2 kB 34.3 MB/s eta 0:00:00 Downloading pystac-1.10.1-py3-none-any.whl (182 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/182.9 kB ? eta -:--:--
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 182.9/182.9 kB 52.6 MB/s eta 0:00:00 Downloading tenacity-8.5.0-py3-none-any.whl (28 kB) Downloading tzdata-2024.1-py2.py3-none-any.whl (345 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/345.4 kB ? eta -:--:-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 345.4/345.4 kB 71.3 MB/s eta 0:00:00 Downloading filelock-3.15.4-py3-none-any.whl (16 kB) Downloading ipytree-0.2.2-py2.py3-none-any.whl (1.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/1.3 MB ? eta -:--:-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.3/1.3 MB 114.3 MB/s eta 0:00:00 Downloading tqdm-4.66.4-py3-none-any.whl (78 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/78.3 kB ? eta -:--:-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.3/78.3 kB 25.0 MB/s eta 0:00:00 Downloading whitebox-2.3.4-py2.py3-none-any.whl (72 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/72.3 kB ? eta -:--:--
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 72.3/72.3 kB 21.5 MB/s eta 0:00:00 Downloading PySocks-1.7.1-py3-none-any.whl (16 kB)
Installing collected packages: colour, whitebox, tzdata, tqdm, tenacity, scooby, python-box, PySocks, pyshp, pyparsing, kiwisolver, geojson, filelock, duckdb, cycler, contourpy, pystac, plotly, pandas, matplotlib, gdown, folium, pystac-client, ipyvue, ipytree, ipyfilechooser, ipyevents, bqplot, whiteboxgui, ipyvuetify, leafmap
Successfully installed PySocks-1.7.1 bqplot-0.12.43 colour-0.1.5 contourpy-1.2.1 cycler-0.12.1 duckdb-1.0.0 filelock-3.15.4 folium-0.17.0 gdown-5.2.0 geojson-3.1.0 ipyevents-2.0.2 ipyfilechooser-0.6.0 ipytree-0.2.2 ipyvue-1.11.1 ipyvuetify-1.9.4 kiwisolver-1.4.5 leafmap-0.35.9 matplotlib-3.9.1 pandas-2.2.2 plotly-5.22.0 pyparsing-3.1.2 pyshp-2.3.1 pystac-1.10.1 pystac-client-0.8.2 python-box-7.2.0 scooby-0.10.0 tenacity-8.5.0 tqdm-4.66.4 tzdata-2024.1 whitebox-2.3.4 whiteboxgui-2.3.0
Note: you may need to restart the kernel to use updated packages.
Out[10]:
In [11]:
Copied!
# %pip install pandas
# import pandas as pd
# df =pd.read_excel(r"C:\Users\16585\OneDrive\Desktop\LJL\pytest.xlsx")
# df['年龄']=df['年龄'].apply(lambda x: x-2)
# ##apply用于对数据进行批量处理,lambda x: x-2表示对每个数据减2
# df.drop('年龄',axis=1,inplace=True)
# ##drop()方法用于删除行或列,axis=1表示删除列,axis=0表示删除行
# ##把列名年龄改成岁数
# df.rename(columns={'年龄':'岁数'},inplace=True)
# ##加一列学习的科目
# df['科目'] = ['Math','English','Chinese']
# ##将新列插入到指定位置
# df.insert(0,'体重',['60','40','59'])
# ##重写一列
# df['姓名'] = ['Tom','Jerry','Lily']
# df.to_excel(r"C:\Users\16585\OneDrive\Desktop\LJL\pytest.xlsx",index=False)
# %pip install pandas
# import pandas as pd
# df =pd.read_excel(r"C:\Users\16585\OneDrive\Desktop\LJL\pytest.xlsx")
# df['年龄']=df['年龄'].apply(lambda x: x-2)
# ##apply用于对数据进行批量处理,lambda x: x-2表示对每个数据减2
# df.drop('年龄',axis=1,inplace=True)
# ##drop()方法用于删除行或列,axis=1表示删除列,axis=0表示删除行
# ##把列名年龄改成岁数
# df.rename(columns={'年龄':'岁数'},inplace=True)
# ##加一列学习的科目
# df['科目'] = ['Math','English','Chinese']
# ##将新列插入到指定位置
# df.insert(0,'体重',['60','40','59'])
# ##重写一列
# df['姓名'] = ['Tom','Jerry','Lily']
# df.to_excel(r"C:\Users\16585\OneDrive\Desktop\LJL\pytest.xlsx",index=False)
In [ ]:
Copied!