- import pandas as pd
- #import random and use it as random.sample
- from random import sample
- #Let us create some data using sample from random module
- #Create two lists
- country_list = ["USA", "Russia","China","India"]
- #Using the name list, let us create three variables using sample() function
- top1 = sample(country_list,4)
- top2 = sample(country_list,4)
- top3 = sample(country_list,4)
- #Now, we can use these lists to create a dataframe with 3 columns
- df = pd.DataFrame({"Top1":top1,
- "Top2":top2,
- "Top3":top3,
- })
- print(df)
Live Programming and Computing with Python, R, Sage, Octave, Maxima, Singular, Gap, GP, HTML & Macaulay2
- Eli
- Senior Expert Member
- Reactions: 189
- Posts: 5931
- Joined: 10 years ago
- Location: Tanzania
- Contact:
Testing Sample Module
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
- Eli
- Senior Expert Member
- Reactions: 189
- Posts: 5931
- Joined: 10 years ago
- Location: Tanzania
- Contact:
Here is a SnapPy, what is it ?
SnapPy is a program for studying the topology and geometry of 3-manifolds, with a focus on hyperbolic structures. It runs on Mac OS X, Linux, and Windows, and combines a link editor and 3D-graphics for Dirichlet domains and cusp neighborhoods with a powerful command-line interface based on the Python programming language.
SnapPy can be installed on Linux as follows:
Ubuntu/Debian/Mint: Tested on Ubuntu 20.04:
Users of Ubuntu 18.04 or older should do:
On TSSFL Stack, SnapPy is installed and can be used via SageMath. We can at once import the whole Stack of SnapPy modules and start testing it immediatelly:
To explore SnapPy Manifold class for example (unfortunately tinker is not installed on SageMath), open Ubuntu LInux Terminal and evoke Python/Ipython interpreter, import Manifold and execute the below simple code:
SnapPy is a program for studying the topology and geometry of 3-manifolds, with a focus on hyperbolic structures. It runs on Mac OS X, Linux, and Windows, and combines a link editor and 3D-graphics for Dirichlet domains and cusp neighborhoods with a powerful command-line interface based on the Python programming language.
SnapPy can be installed on Linux as follows:
Ubuntu/Debian/Mint: Tested on Ubuntu 20.04:
- sudo apt-get install python3-tk python3-pip
- # Note no "sudo" on the next one!
- python3 -m pip install --upgrade --user snappy
- sudo apt-get install python3-tk python3-pip
- # Note no "sudo" on the next two
- python3 -m pip install --upgrade --user pip wheel
- python3 -m pip install --upgrade --user snappy
On TSSFL Stack, SnapPy is installed and can be used via SageMath. We can at once import the whole Stack of SnapPy modules and start testing it immediatelly:
- from snappy import Manifold, Triangulation, Manifold, ManifoldHP, AbelianGroup, FundamentalGroup, HolonomyGroup, HolonomyGroupHP, DirichletDomain, DirichletDomainHP, CuspNeighborhood, CuspNeighborhoodHP, SymmetryGroup, AlternatingKnotExteriors, NonalternatingKnotExteriors, SnapPeaFatalError, InsufficientPrecisionError, pari, twister, OrientableCuspedCensus, NonorientableCuspedCensus, OrientableClosedCensus, NonorientableClosedCensus, LinkExteriors, CensusKnots, HTLinkExteriors, TetrahedralOrientableCuspedCensus, TetrahedralNonorientableCuspedCensus, OctahedralOrientableCuspedCensus, OctahedralNonorientableCuspedCensus, CubicalOrientableCuspedCensus, CubicalNonorientableCuspedCensus, DodecahedralOrientableCuspedCensus, DodecahedralNonorientableCuspedCensus, IcosahedralNonorientableClosedCensus, IcosahedralOrientableClosedCensus, CubicalNonorientableClosedCensus, CubicalOrientableClosedCensus, DodecahedralNonorientableClosedCensus, DodecahedralOrientableClosedCensus, Crossing, Strand, Link, Tangle, RationalTangle, ZeroTangle, InfinityTangle, IdentityBraid, random_link, DTcodec
- A = AbelianGroup(elementary_divisors=[5,15,0,0])
- print(A)
- print(A[0])
- M = Manifold('m004')
- print(M.symmetry_group())
- M = Manifold('K7_1')
- G = M.fundamental_group()
- g = G.generators_in_originals()
- print(g)
- #M.inside_view()
- from snappy import Manifold
- M = Manifold('m004')
- M.inside_view()
- %gui tk
- #Code 2
- from snappy import ManifoldHP
- M = ManifoldHP('14n12345') #Try M = ManifoldHP('15n4321')
- M.volume()
- M.plink()
- M.browse()
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
- Eli
- Senior Expert Member
- Reactions: 189
- Posts: 5931
- Joined: 10 years ago
- Location: Tanzania
- Contact:
- import pandas as pd
- import re
- # Sample data
- data = {'date_time': ['Random text 2023-09-03 00:20:00 more text', 'Some other text', '2023-09-03 00:20:00 additional text']}
- df = pd.DataFrame(data)
- # Extract the first datetime occurrence with the desired format
- pattern = r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}'
- first_datetime = re.search(pattern, ' '.join(df['date_time']))
- if first_datetime:
- # Extract the time from the first datetime occurrence
- first_time = first_datetime.group().split()[1]
- print(first_time)
- else:
- print("Datetime not found in DataFrame.")
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
- Eli
- Senior Expert Member
- Reactions: 189
- Posts: 5931
- Joined: 10 years ago
- Location: Tanzania
- Contact:
Python Polars is an alternative to Pandas, written with performance in mind. Test it:
- import polars as pl
- from datetime import datetime
- df = pl.DataFrame(
- {
- "integer": [1, 2, 3, 4, 5],
- "date": [
- datetime(2023, 1, 1),
- datetime(2023, 1, 2),
- datetime(2023, 1, 3),
- datetime(2023, 1, 4),
- datetime(2023, 1, 5),
- ],
- "float": [4.0, 5.0, 6.0, 7.0, 8.0],
- }
- )
- print(df)
- print(df.sample(2))
- print(df.describe())
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
- Eli
- Senior Expert Member
- Reactions: 189
- Posts: 5931
- Joined: 10 years ago
- Location: Tanzania
- Contact:
Test Vega Altair
- # import altair with an abbreviated alias
- import altair as alt
- # load a sample dataset as a pandas DataFrame
- from vega_datasets import data
- cars = data.cars()
- # make the chart
- chart = alt.Chart(cars).mark_point().encode(
- x='Horsepower',
- y='Miles_per_Gallon',
- color='Origin',
- ).interactive()
- chart.save('chart.html') # Save to file
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
- Eli
- Senior Expert Member
- Reactions: 189
- Posts: 5931
- Joined: 10 years ago
- Location: Tanzania
- Contact:
These libraries are currently available, test:
- import langserve
- import openai
- import langchain
- import langchain_openai
- import sklearn
- import fastapi
- import flask
0
TSSFL -- A Creative Journey Towards Infinite Possibilities!
-
- Similar Topics
- Replies
- Views
- Last post
-
- Information
-
Who is online
Users browsing this forum: No registered users and 0 guests